# Clean up dataframe to keep only meaningful vars and drop NA, ready for LM
tidy_df <- function(src_df, ct, f, drop_islands=TRUE) {
  clean_bei_df <- src_df %>%
    select(CT_UID, all_of(all.vars(f))) %>%
    drop_na() %>%
    units::drop_units()
  
  # Join geom from CT dataframe
  df <- ct %>%
    transmute(CT_UID = GeoUID) %>%
    inner_join(clean_bei_df, by="CT_UID")
  
  # Build neighborhood (with islands) and extract island IDs
  ct_nb <- poly2nb(df)
  
  if (drop_islands) {
    islands <- lapply(ct_nb, min) %>% lapply(function(e) e == 0) %>% unlist %>% which()

    # Cleanup subset DF to drop islands and NA
    df <- df %>%
      filter(!row_number() %in% islands)
  
    # Recompute neighborhood
    ct_nb <- poly2nb(df)
    
    # Clean up final dataframe (no island, no NA's, pure dataframe)
    clean_df <- df %>%
      as.data.frame() %>%
      select(CT_UID, all_of(all.vars(f)))
  }

  nbw = nb2listw(ct_nb, zero.policy = !drop_islands)
  
  list(df=clean_df, nbw=nbw, island_dropped=drop_islands)
}

1 Proposal

1.1 Original grant proposal for Census tract level analyses

1.1.1 Objective 1: Socio-spatial inequalities in urban interventions:

  • To test if urban interventions tend to be located in low SES neighborhoods (H1a); we will run the following model: \[Log(𝔼(UI_{𝑖} \mid X_{𝑖})) = \alpha + \beta_{1} * SES_{𝑖}\] a Poisson regression model with \(UI\) = the number of Urban Interventions between 2016 and 2021, \(SES\) = the socio-economic status of the census track at 2016.
  • To test the reduction in socio-economic inequalities in urban conditions (e.g. length and type of bicycle lanes, NDVI) between 2006 and 2020 (H1b), we will run the following model: \[𝔼(UC_{ij} \mid X_{ij}) = \beta_{0j} + \beta_{1j} ∗ SES + \beta_{2j} ∗ Time + \beta_{3j} ∗ SES ∗ Time + \epsilon_{ij}\] a multilevel linear model with \(UC\) = the Urban condition, \(SES\) = the socio-economic status of the census track.

1.1.2 Objective 2: Examining causal pathways and directionality of intervention/gentrification relation:

  • To test if urban interventions occur before gentrification or if gentrification occurs before the implementation of new urban interventions, we will run two models : (1) \[Logit(𝔼(G_{i} \mid X_{i})) = \alpha + \beta_{1} ∗ UI_{i} + + \beta_{2} ∗ PG_{i} + \beta ∗ X_{control_{i}}\] a logistic regression model among low SES census tracts (2006) with \(G\) = Gentrification between 2006 and 2016, \(UI\) = the number of Urban Interventions between 2001 and 2006, and \(PG\) = SES status 2006; and (2) \[Logit(𝔼(UI_{i} \mid X_{i})) = \alpha + \beta_{1} ∗ G_{i} + \beta_{2} ∗ UC_{i} + \beta ∗ X_{control_{i}}\] a Poisson regression model, with \(UI\) = the number of Urban Interventions between 2016 and 2023, \(G\) = Gentrification between 2006 and 2016, and \(UC\) = Urban Conditions in 2016.

1.2 Paper objective

We focus on obj #1: are urban interventions tend to be located in low SES neighborhoods. Here, the urban interventions considered are bike lanes and canopy/tree coverage and low SES ~ high Pampalon deprivation index. In a second step, we will look at the variations of UI and SES and their association.

Data extraction and pre-analyses for the paper looking at BEI and equity. BEI comprise bike lanes and canopy changes while equity is measured through Pampalon deprivation index. (Partially adapted from original work on BEI bike lanes – see bike_lane_stats.R and ReadMe.md.)

Paper is available here.

General processing steps:

  • Get CT 2016 boundaries (from Cancensus API)
  • Get BEI interventions (canopy / bike lanes) for the selected years (2011 / 2015 / 2016 / 2019)
  • Compute changes between years
    • for the original CT boundaries
    • for buffered CTs (250 / 500 / 750m)

In a second phase, these BEI changes will be linked to Pampalon index for 2016 (and 2011 ?)

1.3 Revision history

UPDATE 2021-12-02 Following discussion with @Yan, add normalized bike line changes:

  • by CT/buffer area
  • by street length within CT/buffer

UPDATE 2021-12-08 Following discussion with @Yan

  • Keep only normalized variation of bike lane length
  • Reverse relation: BEI metric = f(Equity metric (Pampalon / gentrification))
  • Display association at baseline, then add delta over time
  • Canopy : distinguish between high and low canopy

UPDATE 2022-01-14 Following discussion with @Ruben and @Yan

  • Test model with UC 2011 when modeling UI
  • Models with random slope probably not pertinent (see model 6, section 7.1.6)
  • Try to define Year variable as continuous instead of category in LME
  • Check if range of wSCOREMAT matches theoretical range of x-axis in graph (-.2 >> .2), might ponder the magnitude of the observed trend
  • Test three-way interaction instead of 2 times two-way interactions (interactions might be complicated to interpret…)
  • For gentrification and multilevel model, use GEE (logit)

UPDATE 2022-02-10 Following gentrification meeting

  • Add correlation matrix of SES variables (Caislin)
  • Drop wSCORESOC, which does not capture equity dimension (Meghan) [replaced by visible minority]
  • Paper focus should be on gentrification

UPDATE 2022-02-15

  • Add spatial autocorrelation test (Moran’s I)
  • Add Lagrange Multipliers to test best spatial model
  • Add comparison of OLS/SAR/SEM models

2 Built Environment Intervention Extraction

2.1 Bike lane changes

We use data categorized by Philippe Apparicio’s team who manually identified bike lanes for each census year since 1991. For this study, we limit ourselves to 2016 and 2011 census years.

On top of the original CT boundaries, three levels of buffer have been applied to the CT – 250m, 500m & 750m. Then the same series of processing steps (see above) have been applied to the buffers.

# Bike lanes, from Ph. Apparicio
reseau <- st_read(dsn="data/ReseauCyclableFinal.gdb", layer = "Reseau") # Already in NAD83 / MTM zone 8
## Reading layer `Reseau' from data source 
##   `/Users/benoit/WORKSPACE/gentrification_BEI_equity/data/ReseauCyclableFinal.gdb' 
##   using driver `OpenFileGDB'
## Simple feature collection with 82166 features and 72 fields
## Geometry type: GEOMETRY
## Dimension:     XYZ, XYZM
## Bounding box:  xmin: 266985.5 ymin: 5029251 xmax: 320986.1 ymax: 5062652
## z_range:       zmin: 0 zmax: 43
## m_range:       mmin: 0 mmax: 43
## Projected CRS: NAD83 / MTM zone 8
bike_lane <- reseau %>%
  filter(An2016 == 1 | An2011 == 1) %>%
  select(IdRte, ClsRte, Zone, starts_with("An"), starts_with("Typo_")) %>%
  st_cast("MULTILINESTRING") # Get rid of a few MULTICURVE geometries

# CT boundaries for Montreal
CT16 <- get_census(dataset='CA16', regions=list(CMA='24462'), level='CT', geo_format = "sf") %>%
  filter(Type == "CT") %>%
  mutate(interact_aoi = CD_UID %in% c(2466, 2465, 2458)) %>% # Flag Montréal island, Laval and the South shore (Longueuil, St-Lambert, Brossard)
  st_transform(st_crs(bike_lane))
## Reading geo data from local cache.
CT11 <- get_census(dataset='CA11', regions=list(CMA='24462'), level='CT', geo_format = "sf") %>%
  filter(Type == "CT") %>%
  st_transform(st_crs(bike_lane))
## Reading geo data from local cache.
compute_bikelane_by_area <- function(sf_areas, year_fld, typo_fld) {
  # Compute length of bike lanes within each area.
  # --
  # Parameters:
  #   - sf_areas: sf class object defining the areas of interest, must have a GeoUID field
  #   - year_fld: field name specifying the year of interest, e.g. An2016
  #   - typo_fld: field name specifying the typology for the year of interest, e.g. Typo_2016
  
  year_fld <- enquo(year_fld)
  typo_fld <- enquo(typo_fld)
  
  # Compute intersection of bike lanes with areas
  bk <- bike_lane %>%
    filter(!!year_fld == 1) %>%
    st_intersection(sf_areas) %>%
    mutate(bike_lane_length = st_length(.)) %>%
    as.data.frame() %>%
    group_by(GeoUID, !!typo_fld) %>%
    summarise(bike_lane_length = sum(bike_lane_length)) %>%
    ungroup() %>%
    pivot_wider(names_from = !!typo_fld, names_prefix = "Bike_class", names_sort = TRUE,
                values_from = bike_lane_length, values_fill = units::set_units(0, m)) %>%
    mutate(Bike_lane_total = units::set_units(rowSums(select(., starts_with("Bike_class"))), m))
  
  # Merge back into original sf_areas
  bk <- sf_areas %>%
    left_join(bk)
  
  # Replace NA by 0, which occur in Bike_class length
  bk[is.na(bk)] <- 0
  
  return(bk)
}

compute_streetlength_by_area <- function(sf_areas) {
  # Compute length of streets within each area.
  # --
  # Parameters:
  #   - sf_areas: sf class object defining the areas of interest, must have a GeoUID field

  # Compute intersection of streets with areas
  bk <- reseau  %>%
    st_cast("MULTILINESTRING") %>% # Get rid of a few MULTICURVE geometries
    st_intersection(sf_areas) %>%
    mutate(street_length = st_length(.)) %>%
    as.data.frame() %>%
    group_by(GeoUID) %>%
    summarise(street_length = sum(street_length)) %>%
    ungroup()
  
  # Merge back into original sf_areas
  bk <- sf_areas %>%
    mutate(shape_area_km2 = units::set_units(st_area(.), 'km^2')) %>%
    left_join(bk)
  
  # Replace NA by 0
  bk[is.na(bk)] <- 0
  
  return(bk)
}


# Compute year 2016 and year 2011 bike lanes within 2016 CTs
# NB: contrary to the original work, we keep the same area of reference, i.e. 2016
bike_lane_by_CT16 <- compute_bikelane_by_area(CT16, An2016, Typo_2016)
bike_lane_by_CT11 <- compute_bikelane_by_area(CT16, An2011, Typo_2011)
bike_lane_by_CT06 <- compute_bikelane_by_area(CT16, An2006, Typo_2006)

# Compute buffers, with 3 radii and for each census year
radii <- c(250, 500, 750)

buf_CT16 <- lapply(radii, st_buffer, x=CT16)
names(buf_CT16) <- lapply(radii, function(b) {paste0("buf", b)})

# Compute bike length for each buffer/census year
buf_CT16_w_bike_length <- lapply(buf_CT16, compute_bikelane_by_area, year_fld=An2016, typo_fld=Typo_2016)
names(buf_CT16_w_bike_length) <- lapply(radii, function(b) {paste0("buf", b)})
buf_CT16_w_bike_length$original <- bike_lane_by_CT16

buf_CT11_w_bike_length <- lapply(buf_CT16, compute_bikelane_by_area, year_fld=An2011, typo_fld=Typo_2011)
names(buf_CT11_w_bike_length) <- lapply(radii, function(b) {paste0("buf", b)})
buf_CT11_w_bike_length$original <- bike_lane_by_CT11

buf_CT06_w_bike_length <- lapply(buf_CT16, compute_bikelane_by_area, year_fld=An2006, typo_fld=Typo_2006)
names(buf_CT06_w_bike_length) <- lapply(radii, function(b) {paste0("buf", b)})
buf_CT06_w_bike_length$original <- bike_lane_by_CT06

# Compute total street length within CT/buffer
street_length_by_CT16 <- compute_streetlength_by_area(CT16)
buf_CT16_street_length <- lapply(buf_CT16, compute_streetlength_by_area)
names(buf_CT16_street_length) <- lapply(radii, function(b) {paste0("buf", b)})
buf_CT16_street_length$original <- street_length_by_CT16

# Reorganize data to have all data in one dataframe
bike_lane_changes <- CT16 %>%
  left_join(select(as.data.frame(buf_CT16_street_length$original), GeoUID, street_length, shape_area_km2), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT16_street_length$buf250), GeoUID, street_length, shape_area_km2), by="GeoUID", suffix=c(".ct", ".b250")) %>%
  left_join(select(as.data.frame(buf_CT16_street_length$buf500), GeoUID, street_length, shape_area_km2), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT16_street_length$buf750), GeoUID, street_length, shape_area_km2), by="GeoUID", suffix=c(".b500", ".b750")) %>%
  left_join(select(as.data.frame(buf_CT16_w_bike_length$original), GeoUID, starts_with("Bike_")), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT11_w_bike_length$original), GeoUID, starts_with("Bike_")), by="GeoUID", suffix=c(".2016ct", ".2011ct")) %>%
  left_join(select(as.data.frame(buf_CT16_w_bike_length$buf250), GeoUID, starts_with("Bike_")), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT11_w_bike_length$buf250), GeoUID, starts_with("Bike_")), by="GeoUID", suffix=c(".2016b250", ".2011b250")) %>%
  left_join(select(as.data.frame(buf_CT16_w_bike_length$buf500), GeoUID, starts_with("Bike_")), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT11_w_bike_length$buf500), GeoUID, starts_with("Bike_")), by="GeoUID", suffix=c(".2016b500", ".2011b500")) %>%
  left_join(select(as.data.frame(buf_CT16_w_bike_length$buf750), GeoUID, starts_with("Bike_")), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT11_w_bike_length$buf750), GeoUID, starts_with("Bike_")), by="GeoUID", suffix=c(".2016b750", ".2011b750")) %>%
  left_join(select(as.data.frame(buf_CT06_w_bike_length$original), GeoUID, starts_with("Bike_")), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT06_w_bike_length$buf250), GeoUID, starts_with("Bike_")), by="GeoUID", suffix=c(".2006ct", ".2006b250")) %>%
  left_join(select(as.data.frame(buf_CT06_w_bike_length$buf500), GeoUID, starts_with("Bike_")), by="GeoUID") %>%
  left_join(select(as.data.frame(buf_CT06_w_bike_length$buf750), GeoUID, starts_with("Bike_")), by="GeoUID", suffix=c(".2006b500", ".2006b750"))

# Compute ratio of bike lane vs street length
bike_lane_changes <- bike_lane_changes %>%
  mutate(Bike_lane.by.street.2011ct = 100 * Bike_lane_total.2011ct / street_length.ct,
         Bike_lane.by.street.2011b250 = 100 * Bike_lane_total.2011b250 / street_length.b250,
         Bike_lane.by.street.2011b500 = 100 * Bike_lane_total.2011b500 / street_length.b500,
         Bike_lane.by.street.2011b750 = 100 * Bike_lane_total.2011b750 / street_length.b750,
         Bike_lane.by.street.2016ct = 100 * Bike_lane_total.2016ct / street_length.ct,
         Bike_lane.by.street.2016b250 = 100 * Bike_lane_total.2016b250 / street_length.b250,
         Bike_lane.by.street.2016b500 = 100 * Bike_lane_total.2016b500 / street_length.b500,
         Bike_lane.by.street.2016b750 = 100 * Bike_lane_total.2016b750 / street_length.b750,
         Bike_lane.by.street.2006ct = 100 * Bike_lane_total.2006ct / street_length.ct,
         Bike_lane.by.street.2006b250 = 100 * Bike_lane_total.2006b250 / street_length.b250,
         Bike_lane.by.street.2006b500 = 100 * Bike_lane_total.2006b500 / street_length.b500,
         Bike_lane.by.street.2006b750 = 100 * Bike_lane_total.2006b750 / street_length.b750)

# Compute change between 2011 and 2016 (only for total bike lane length)
bike_lane_changes <- bike_lane_changes %>%
  mutate(Bike_lane_diff.2011.2016ct = Bike_lane_total.2016ct - Bike_lane_total.2011ct,
         Bike_lane_diff.2011.2016b250 = Bike_lane_total.2016b250 - Bike_lane_total.2011b250,
         Bike_lane_diff.2011.2016b500 = Bike_lane_total.2016b500 - Bike_lane_total.2011b500,
         Bike_lane_diff.2011.2016b750 = Bike_lane_total.2016b750 - Bike_lane_total.2011b750)

# Normalize bike lane change by (i) street length and (ii) area
bike_lane_changes <- bike_lane_changes %>%
  mutate(Bike_lane_diff.by.street.2011.2016ct = 100 * Bike_lane_diff.2011.2016ct / street_length.ct,
         Bike_lane_diff.by.street.2011.2016b250 = 100 * Bike_lane_diff.2011.2016b250 / street_length.b250,
         Bike_lane_diff.by.street.2011.2016b500 = 100 * Bike_lane_diff.2011.2016b500 / street_length.b500,
         Bike_lane_diff.by.street.2011.2016b750 = 100 * Bike_lane_diff.2011.2016b750 / street_length.b750,
         Bike_lane_diff.by.area.2011.2016ct = Bike_lane_diff.2011.2016ct / shape_area_km2.ct,
         Bike_lane_diff.by.area.2011.2016b250 = Bike_lane_diff.2011.2016b250 / shape_area_km2.b250,
         Bike_lane_diff.by.area.2011.2016b500 = Bike_lane_diff.2011.2016b500 / shape_area_km2.b500,
         Bike_lane_diff.by.area.2011.2016b750 = Bike_lane_diff.2011.2016b750 / shape_area_km2.b750)

# Save results
st_write(bike_lane_changes, dsn = "data/bike_length_changes.gpkg", delete_layer = TRUE)
## Deleting layer `bike_length_changes' using driver `GPKG'
## Writing layer `bike_length_changes' to data source 
##   `data/bike_length_changes.gpkg' using driver `GPKG'
## Writing 970 features with 140 fields and geometry type Multi Polygon.
# Clean up
rm(buf_CT16)
rm(bike_lane_by_CT11, bike_lane_by_CT16, bike_lane_by_CT06)
rm(buf_CT11_w_bike_length, buf_CT16_w_bike_length, buf_CT06_w_bike_length)
rm(street_length_by_CT16, buf_CT16_street_length, buf_CT06_street_length)

2.1.1 Illustration of bike lane metrics

Check output for one specific dataset (Census tracts 2016, no buffer)

2.1.1.1 Raw length

Bike lane length in 2016 within CTs, measured in meters

ggplot() +
   geom_sf(data=filter(bike_lane_changes, interact_aoi), mapping = aes(fill=as.numeric(Bike_lane_total.2016ct)), lwd=0) +
  scale_fill_continuous(name = "Total length (m)")+ 
  labs(title = "Length of bike lanes within 2016 CTs", subtitle = "(INTERACT study area || for control only)")

2.1.1.2 Absolute length change

Absolute bike lane length change between 2011 and 2016, in meters

ggplot() +
   geom_sf(data=filter(bike_lane_changes, interact_aoi), mapping = aes(fill=as.numeric(Bike_lane_diff.2011.2016ct)), lwd=0) +
  scale_fill_gradient2(name = "Length (m)")+ 
  labs(title = "Changes in bike lane between 2011 and 2016", subtitle = "(INTERACT study area || CT level || for control only)")

2.1.1.3 Normalized length change (by street)

Relative bike lane length change between 2011 and 2016, normalized by street length within CT in 2016, expressed in %

\[Variation = \frac{Bike Lane_{2016}}{Street Length_{2016}} - \frac{Bike Lane_{2011}}{Street Length_{2016}}\]

ggplot() +
   geom_sf(data=filter(bike_lane_changes, interact_aoi), mapping = aes(fill=as.numeric(Bike_lane_diff.by.street.2011.2016ct)), lwd=0) +
  scale_fill_gradient2(name = "Variation (%)")+ 
  labs(title = "Changes in bike lane between 2011 and 2016, normalized by street", subtitle = "(INTERACT study area || CT level || for control only)")

2.1.1.4 Normalized length change (by area)

Relative bike lane length change between 2011 and 2016, normalized by CT area, expressed in \(\frac{km}{km^{2}}\)

\[Ratio = \frac{Bike Lane_{2016}}{CT Area_{2016}} - \frac{Bike Lane_{2011}}{CT Area_{2016}}\]

ggplot() +
   geom_sf(data=filter(bike_lane_changes, interact_aoi), mapping = aes(fill=as.numeric(Bike_lane_diff.by.area.2011.2016ct)), lwd=0) +
  scale_fill_gradient2(name = "Ratio (1/km)")+ 
  labs(title = "Changes in bike lane between 2011 and 2016, normalized by area", subtitle = "(INTERACT study area || CT level || for control only)")

2.1.1.5 Normalized length change (by street) NEW

After some discussion with Yan, we envision using a relative bike lane length ratio change between 2011 and 2016, normalized by the ratio in 2011, expressed in %

\[Variation = \frac{\frac{Bike Lane_{2016}}{Street Length_{2016}} - \frac{Bike Lane_{2011}}{Street Length_{2016}}}{\frac{Bike Lane_{2011}}{Street Length_{2016}}} = \frac{Bike Lane_{2016} - Bike Lane_{2011}}{Bike Lane_{2011}}\]

Problem: all CT with no bike lane in 2011 get a missing data, contrary to the original metric, which measured the absolute variation of the ratio of bike lane to street length.

.bike_lane_changes <- bike_lane_changes %>%
  mutate(Bike_lane_diff.by.street.relative.2011.2016ct = Bike_lane_diff.by.street.2011.2016ct / (Bike_lane_total.2011ct / street_length.ct))

ggplot() +
   geom_sf(data=filter(.bike_lane_changes, interact_aoi), mapping = aes(fill=as.numeric(Bike_lane_diff.by.street.relative.2011.2016ct)), lwd=0) +
  scale_fill_gradient2(name = "Ratio")+ 
  labs(title = "Changes in bike lane ratio between 2011 and 2016, normalized by ratio in 2011", subtitle = "(INTERACT study area || CT level || for control only)")

2.1.2 Basic stats on each layer

2.1.2.1 Census Tracts

# CT level
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.2011.2016ct)), binwidth = 250) + 
  xlab("Difference of bike lane length between 2016 and 2011 | CT level")

summary(bike_lane_changes$Bike_lane_diff.2011.2016ct)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -1377.7     0.0     0.0   262.1   189.7 14463.8
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.street.2011.2016ct))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by street")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 252 rows containing non-finite values (stat_bin).

summary(bike_lane_changes$Bike_lane_diff.by.street.2011.2016ct)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
## -100.000    0.000    0.000    3.665    4.496  100.000      252
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.area.2011.2016ct))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by area")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

summary(bike_lane_changes$Bike_lane_diff.by.area.2011.2016ct)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -1.1474  0.0000  0.0000  0.4237  0.1764  8.9852
ggplot(.bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.street.relative.2011.2016ct))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by ratio in 2011")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 461 rows containing non-finite values (stat_bin).

summary(.bike_lane_changes$Bike_lane_diff.by.street.relative.2011.2016ct)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max.      NA's 
## -100.0000    0.0000    0.2199       Inf  102.7796       Inf       367

2.1.2.2 Buffers 250m

# buf250 level
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.2011.2016b250)), binwidth = 250) + 
  xlab("Difference of bike lane length between 2016 and 2011 | buf 250m")

summary(bike_lane_changes$Bike_lane_diff.2011.2016b250)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -3452.5     0.0     0.0   646.7   933.8 20786.8
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.street.2011.2016b250))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by street")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 233 rows containing non-finite values (stat_bin).

summary(bike_lane_changes$Bike_lane_diff.by.street.2011.2016b250)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
## -38.5802   0.0000   0.8538   3.3168   4.9043  56.6588      233
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.area.2011.2016b250))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by area")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

summary(bike_lane_changes$Bike_lane_diff.by.area.2011.2016b250)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -1.4622  0.0000  0.0000  0.4001  0.4306  6.2156

2.1.2.3 Buffers 500m

# buf500 level
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.2011.2016b500)), binwidth = 250) + 
  xlab("Difference of bike lane length between 2016 and 2011 | buf 500m")

summary(bike_lane_changes$Bike_lane_diff.2011.2016b250)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -3452.5     0.0     0.0   646.7   933.8 20786.8
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.street.2011.2016b500))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by street")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 229 rows containing non-finite values (stat_bin).

summary(bike_lane_changes$Bike_lane_diff.by.street.2011.2016b500)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
## -26.891   0.000   1.385   3.298   5.323  22.121     229
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.area.2011.2016b500))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by area")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

summary(bike_lane_changes$Bike_lane_diff.by.area.2011.2016b500)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.94397  0.00000  0.03393  0.38745  0.49370  4.00417

2.1.2.4 Buffers 750m

# buf750 level
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.2011.2016b750)), binwidth = 250) + 
  xlab("Difference of bike lane length between 2016 and 2011 | buf 750m")

summary(bike_lane_changes$Bike_lane_diff.2011.2016b750)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -3697.5     0.0   578.6  1842.2  2928.6 29325.1
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.street.2011.2016b750))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by street")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 222 rows containing non-finite values (stat_bin).

summary(bike_lane_changes$Bike_lane_diff.by.street.2011.2016b750)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
## -4.7579  0.1418  1.7793  3.2961  5.2054 22.5448     222
ggplot(bike_lane_changes) +
  geom_histogram(aes(as.numeric(Bike_lane_diff.by.area.2011.2016b750))) + 
  xlab("Difference of bike lane length between 2016 and 2011, normalized by area")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

summary(bike_lane_changes$Bike_lane_diff.by.area.2011.2016b750)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.59760  0.00000  0.07793  0.38166  0.53774  3.95463

2.2 Canopy changes

Canopy changes is based on data produced by CMM, using multispectral aerial imagery and lidar. In order to sync the observations with the census years, we focus on 2011 and 2019 with one extra observation point in 2015.

The processing steps are similar to the ones for the bike lanes:

  • Import the raster for each of the 3 years
  • Compute proportion of canopy within each area level (CT and buffers) for the 3 years
# Codes du raster "espace vert"
# 0. No data (hors CMM)
# 1. NDVI < 0,3 et MNH < 3,0m = Minéral bas (route, stationnement, etc.)
# 2. NDVI < 0,3 et MNH ≥ 3,0m = Minéral haut (constructions)
# 3. NDVI ≥ 0,3 et MNH < 3,0m = Végétal bas (culture, gazon, etc.)
# 4. NDVI ≥ 0,3 et MNH ≥ 3,0m = Végétal haut (canopée)
# 5. Aquatique

# Load rasters into pg database for further processing
system('psql -d gentrif_bei -c "CREATE EXTENSION IF NOT EXISTS postgis"')
system('psql -d gentrif_bei -c "CREATE EXTENSION IF NOT EXISTS postgis_raster"')

if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2019') IS NOT NULL;")) == 0) {
  system("raster2pgsql -s 32188 -I -C -M data/canopy/2019/*.tif -F -t 1000x1000 canopee2019 | psql -d gentrif_bei", intern = TRUE)
} else { message("PG Raster 'canopee2019' already imported") }
## PG Raster 'canopee2019' already imported
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2017') IS NOT NULL;")) == 0) {
  system("raster2pgsql -s 32188 -I -C -M data/canopy/2017/*.tif -F -t 1000x1000 canopee2017 | psql -d gentrif_bei", intern = TRUE)
} else { message("PG Raster 'canopee2017' already imported") }
## PG Raster 'canopee2017' already imported
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2015') IS NOT NULL;")) == 0) {
  system("raster2pgsql -s 32188 -I -C -M data/canopy/2015/*.tif -F -t 1000x1000 canopee2015 | psql -d gentrif_bei", intern = TRUE)
} else { message("PG Raster 'canopee2015' already imported") }
## PG Raster 'canopee2015' already imported
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2011') IS NOT NULL;")) == 0) {
  system("raster2pgsql -s 32188 -I -C -M data/canopy/2011/*.tif -F -t 1000x1000 canopee2011 | psql -d gentrif_bei", intern = TRUE)
} else { message("PG Raster 'canopee2011' already imported") }
## PG Raster 'canopee2011' already imported
# Resample to 10m as the original rasters have a 1m resolution, which is too high to allow for a swift processing
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2019_10m') IS NOT NULL;")) == 0) {
  system("gdal_translate -of GTiff PG:\"host=localhost dbname=gentrif_bei table=canopee2019 mode=2\" -r mode -tr 10 10 data/canopy/canopee2019_10m.tif")
  system("raster2pgsql -s 32188 -I -C -M data/canopy/canopee2019_10m.tif -F -t 100x100 canopee2019_10m | psql -d gentrif_bei")
} else { message("PG Raster 'canopee2019_10m' already imported") }
## PG Raster 'canopee2019_10m' already imported
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2017_10m') IS NOT NULL;")) == 0) {
  system("gdal_translate -of GTiff PG:\"host=localhost dbname=gentrif_bei table=canopee2017 mode=2\" -r mode -tr 10 10 data/canopy/canopee2017_10m.tif")
  system("raster2pgsql -s 32188 -I -C -M data/canopy/canopee2017_10m.tif -F -t 100x100 canopee2017_10m | psql -d gentrif_bei")
} else { message("PG Raster 'canopee2017_10m' already imported") }
## PG Raster 'canopee2017_10m' already imported
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2015_10m') IS NOT NULL;")) == 0) {
  system("gdal_translate -of GTiff PG:\"host=localhost dbname=gentrif_bei table=canopee2015 mode=2\" -r mode -tr 10 10 data/canopy/canopee2015_10m.tif")
  system("raster2pgsql -s 32188 -I -C -M data/canopy/canopee2015_10m.tif -F -t 100x100 canopee2015_10m | psql -d gentrif_bei")
} else { message("PG Raster 'canopee2015_10m' already imported") }
## PG Raster 'canopee2015_10m' already imported
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('canopee2011_10m') IS NOT NULL;")) == 0) {
  system("gdal_translate -of GTiff PG:\"host=localhost dbname=gentrif_bei table=canopee2011 mode=2\" -r mode -tr 10 10 data/canopy/canopee2011_10m.tif")
  system("raster2pgsql -s 32188 -I -C -M data/canopy/canopee2011_10m.tif -F -t 100x100 canopee2011_10m | psql -d gentrif_bei")
} else { message("PG Raster 'canopee2011_10m' already imported") }
## PG Raster 'canopee2011_10m' already imported
# Push CT16 to pg
if (nrow(dbGetQuery(con_bei, "SELECT 1 test WHERE to_regclass('ct16') IS NOT NULL;")) == 0) {
  CT16 %>%
    st_transform(crs = 32188) %>%
    st_write(con_bei, "ct16",
             layer_options = c("OVERWRITE=yes", "LAUNDER=true", "SPATIAL_INDEX=gist", "GEOMETRY_NAME=geom"))
  system("psql -d gentrif_bei -c 'CREATE INDEX ON  ct16 USING gist (geometry)'")
} else { message("PG Layer CT16 already imported") }
## PG Layer CT16 already imported

2.2.1 Extract % of green spaces at various scales

UPDATE 2021-12-08: following discussion with Yan, we decide to focus on extracting canopy years in sync with census years, i.e. 2011 and 2017, and 2015 as an intermediary year. (Previously, we were using the last available year, i.e. 2019), plus keep the option of looking high/low canopy separately

UPDATE 2022-02-09: adding the number of sq.m per inhabitant within census. when population of census equal or below 5 inhabitants.

2.2.1.1 Census Tracts

WITH cnt19 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2019_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee19 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2019_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2019
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2019
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2019
    FROM cnt19
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt17 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2017_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee17 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2017_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2017
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2017
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2017
    FROM cnt17
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt15 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2015_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee15 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2015_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2015
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2015
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2015
    FROM cnt15
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt11 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2011_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee11 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2011_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2011
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2011
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2011
    FROM cnt11
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
)
SELECT "GeoUID"
    ,st_area(geometry) ct_area_m2
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2011_by_pop, 0) END m2_esp_vert_2011_by_pop
    ,coalesce(pct_esp_vert_low_2011, 0) pct_esp_vert_low_2011
    ,coalesce(pct_esp_vert_high_2011, 0) pct_esp_vert_high_2011
    ,coalesce(pct_esp_vert_2011, 0) pct_esp_vert_2011
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2015_by_pop, 0) END m2_esp_vert_2015_by_pop
    ,coalesce(pct_esp_vert_low_2015, 0) pct_esp_vert_low_2015
    ,coalesce(pct_esp_vert_high_2015, 0) pct_esp_vert_high_2015
    ,coalesce(pct_esp_vert_2015, 0) pct_esp_vert_2015
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2017_by_pop, 0) END m2_esp_vert_2017_by_pop
    ,coalesce(pct_esp_vert_low_2017, 0) pct_esp_vert_low_2017
    ,coalesce(pct_esp_vert_high_2017, 0) pct_esp_vert_high_2017
    ,coalesce(pct_esp_vert_2017, 0) pct_esp_vert_2017
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2019_by_pop, 0) END m2_esp_vert_2019_by_pop
    ,coalesce(pct_esp_vert_low_2019, 0) pct_esp_vert_low_2019
    ,coalesce(pct_esp_vert_high_2019, 0) pct_esp_vert_high_2019
    ,coalesce(pct_esp_vert_2019, 0) pct_esp_vert_2019
FROM ct16
FULL JOIN canopee19 USING ("GeoUID")
FULL JOIN canopee17 USING ("GeoUID")
FULL JOIN canopee15 USING ("GeoUID")
FULL JOIN canopee11 USING ("GeoUID");

2.2.1.2 Buffers 250m

WITH ct16 AS (
    select "GeoUID", "Population", ST_Buffer(geometry, 250) geometry
    from ct16
),
cnt19 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2019_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee19 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2019_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2019
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2019
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2019
    FROM cnt19
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt17 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2017_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee17 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2017_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2017
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2017
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2017
    FROM cnt17
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt15 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2015_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee15 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2015_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2015
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2015
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2015
    FROM cnt15
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt11 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2011_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee11 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2011_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2011
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2011
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2011
    FROM cnt11
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
)
SELECT "GeoUID"
    ,st_area(geometry) ct_area_m2
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2011_by_pop, 0) END m2_esp_vert_2011_by_pop
    ,coalesce(pct_esp_vert_low_2011, 0) pct_esp_vert_low_2011
    ,coalesce(pct_esp_vert_high_2011, 0) pct_esp_vert_high_2011
    ,coalesce(pct_esp_vert_2011, 0) pct_esp_vert_2011
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2015_by_pop, 0) END m2_esp_vert_2015_by_pop
    ,coalesce(pct_esp_vert_low_2015, 0) pct_esp_vert_low_2015
    ,coalesce(pct_esp_vert_high_2015, 0) pct_esp_vert_high_2015
    ,coalesce(pct_esp_vert_2015, 0) pct_esp_vert_2015
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2017_by_pop, 0) END m2_esp_vert_2017_by_pop
    ,coalesce(pct_esp_vert_low_2017, 0) pct_esp_vert_low_2017
    ,coalesce(pct_esp_vert_high_2017, 0) pct_esp_vert_high_2017
    ,coalesce(pct_esp_vert_2017, 0) pct_esp_vert_2017
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2019_by_pop, 0) END m2_esp_vert_2019_by_pop
    ,coalesce(pct_esp_vert_low_2019, 0) pct_esp_vert_low_2019
    ,coalesce(pct_esp_vert_high_2019, 0) pct_esp_vert_high_2019
    ,coalesce(pct_esp_vert_2019, 0) pct_esp_vert_2019
FROM ct16
FULL JOIN canopee19 USING ("GeoUID")
FULL JOIN canopee17 USING ("GeoUID")
FULL JOIN canopee15 USING ("GeoUID")
FULL JOIN canopee11 USING ("GeoUID");

2.2.1.3 Buffers 500m

WITH ct16 AS (
    select "GeoUID", "Population", ST_Buffer(geometry, 500) geometry
    from ct16
),
cnt19 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2019_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee19 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2019_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2019
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2019
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2019
    FROM cnt19
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt17 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2017_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee17 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2017_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2017
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2017
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2017
    FROM cnt17
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt15 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2015_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee15 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2015_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2015
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2015
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2015
    FROM cnt15
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt11 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2011_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee11 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2011_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2011
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2011
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2011
    FROM cnt11
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
)
SELECT "GeoUID"
    ,st_area(geometry) ct_area_m2
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2011_by_pop, 0) END m2_esp_vert_2011_by_pop
    ,coalesce(pct_esp_vert_low_2011, 0) pct_esp_vert_low_2011
    ,coalesce(pct_esp_vert_high_2011, 0) pct_esp_vert_high_2011
    ,coalesce(pct_esp_vert_2011, 0) pct_esp_vert_2011
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2015_by_pop, 0) END m2_esp_vert_2015_by_pop
    ,coalesce(pct_esp_vert_low_2015, 0) pct_esp_vert_low_2015
    ,coalesce(pct_esp_vert_high_2015, 0) pct_esp_vert_high_2015
    ,coalesce(pct_esp_vert_2015, 0) pct_esp_vert_2015
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2017_by_pop, 0) END m2_esp_vert_2017_by_pop
    ,coalesce(pct_esp_vert_low_2017, 0) pct_esp_vert_low_2017
    ,coalesce(pct_esp_vert_high_2017, 0) pct_esp_vert_high_2017
    ,coalesce(pct_esp_vert_2017, 0) pct_esp_vert_2017
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2019_by_pop, 0) END m2_esp_vert_2019_by_pop
    ,coalesce(pct_esp_vert_low_2019, 0) pct_esp_vert_low_2019
    ,coalesce(pct_esp_vert_high_2019, 0) pct_esp_vert_high_2019
    ,coalesce(pct_esp_vert_2019, 0) pct_esp_vert_2019
FROM ct16
FULL JOIN canopee19 USING ("GeoUID")
FULL JOIN canopee17 USING ("GeoUID")
FULL JOIN canopee15 USING ("GeoUID")
FULL JOIN canopee11 USING ("GeoUID");

2.2.1.4 Buffers 750m

WITH ct16 AS (
    select "GeoUID", "Population", ST_Buffer(geometry, 750) geometry
    from ct16
),
cnt19 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2019_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee19 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2019_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2019
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2019
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2019
    FROM cnt19
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt17 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2017_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee17 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2017_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2017
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2017
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2017
    FROM cnt17
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt15 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2015_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee15 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2015_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2015
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2015
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2015
    FROM cnt15
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
),
cnt11 AS (
    SELECT "GeoUID", "Population"
        ,(pvc).value, SUM((pvc).count) As total
    FROM (SELECT "GeoUID", "Population"
            ,ST_ValueCount(ST_Clip(rast, geometry)) As pvc
        FROM canopee2011_10m
        JOIN ct16 ON ST_Intersects(geometry, rast)
    ) As foo
    GROUP BY "GeoUID", "Population", (pvc).value
),
canopee11 AS (
    SELECT "GeoUID"
        ,round(10.*10. * sum(total) FILTER (WHERE value in (3, 4)) / NULLIF("Population", 0), 1) AS m2_esp_vert_2011_by_pop
        ,round(100. * sum(total) FILTER (WHERE value in (3, 4)) / sum(total), 2) AS pct_esp_vert_2011
        ,round(100. * sum(total) FILTER (WHERE value = 3) / sum(total), 2) AS pct_esp_vert_low_2011
        ,round(100. * sum(total) FILTER (WHERE value = 4) / sum(total), 2) AS pct_esp_vert_high_2011
    FROM cnt11
    WHERE value > 0 -- discard no data, including postgis raster no data
    GROUP BY "GeoUID", "Population"
)
SELECT "GeoUID"
    ,st_area(geometry) ct_area_m2
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2011_by_pop, 0) END m2_esp_vert_2011_by_pop
    ,coalesce(pct_esp_vert_low_2011, 0) pct_esp_vert_low_2011
    ,coalesce(pct_esp_vert_high_2011, 0) pct_esp_vert_high_2011
    ,coalesce(pct_esp_vert_2011, 0) pct_esp_vert_2011
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2015_by_pop, 0) END m2_esp_vert_2015_by_pop
    ,coalesce(pct_esp_vert_low_2015, 0) pct_esp_vert_low_2015
    ,coalesce(pct_esp_vert_high_2015, 0) pct_esp_vert_high_2015
    ,coalesce(pct_esp_vert_2015, 0) pct_esp_vert_2015
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2017_by_pop, 0) END m2_esp_vert_2017_by_pop
    ,coalesce(pct_esp_vert_low_2017, 0) pct_esp_vert_low_2017
    ,coalesce(pct_esp_vert_high_2017, 0) pct_esp_vert_high_2017
    ,coalesce(pct_esp_vert_2017, 0) pct_esp_vert_2017
    ,CASE WHEN "Population" <= 5 THEN NULL ELSE COALESCE(m2_esp_vert_2019_by_pop, 0) END m2_esp_vert_2019_by_pop
    ,coalesce(pct_esp_vert_low_2019, 0) pct_esp_vert_low_2019
    ,coalesce(pct_esp_vert_high_2019, 0) pct_esp_vert_high_2019
    ,coalesce(pct_esp_vert_2019, 0) pct_esp_vert_2019
FROM ct16
FULL JOIN canopee19 USING ("GeoUID")
FULL JOIN canopee17 USING ("GeoUID")
FULL JOIN canopee15 USING ("GeoUID")
FULL JOIN canopee11 USING ("GeoUID");

2.3 Pampalon index

Get it here

pampalon <- read.xlsx("data/Canada2016Pampalon/A-MSDIData_Can2016_eng/1. EquivalenceTableCanada2016_ENG.xlsx", sheet = 2) %>%
  mutate(DA = as.character(DA)) %>%
  select(DA, SCOREMAT, SCORESOC)

# 2016 DA boundaries for Montreal
DA16 <- get_census(dataset='CA16', regions=list(CMA='24462'), level='DA', geo_format = "sf") %>%
  filter(Type == "DA") %>%
  st_transform(st_crs(bike_lane))
## Reading geo data from local cache.
pampalon <- DA16 %>%
  inner_join(pampalon, by = c("GeoUID" = "DA")) %>%
  as.data.frame()

# Get Pampalon 2006
pampalon06 <- read.xlsx("data/Canada2006Pampalon/A-MSDIData_Can2006_eng/1. CorrespondenceTable_Can2006_eng.xlsx", sheet = 2) %>%
  mutate(DA = as.character(DA)) %>%
  select(DA, DAPOP2006, SCOREMAT, SCORESOC)

# Get LUT DA2006 <-> DA2011 from StatCan
lut_da.1 <- read.csv("data/2011_92-156_DA_AD_txt/2011_92-156_DA_AD.txt", colClasses = "character", 
                     header = FALSE, col.names = c("DAUID2011.ADIDU2011", "DAUID2006.ADIDU2006", "DBUID2011", "DA_rel_flag")) %>%
  select(!c(DBUID2011, DA_rel_flag)) %>%
  unique()

# Link Pampalon 2011 to LUT and compute weighted mean of scores of Pampalon 2011
# NB: population numbers will diverge from  reality when more than one DA is merged into one DA of next census
pampalon06.11 <- pampalon06 %>%
  inner_join(lut_da.1, by = c("DA" = "DAUID2006.ADIDU2006")) %>%
  group_by(DAUID2011.ADIDU2011) %>%
  summarise(pop2006 = sum(DAPOP2006),
            SCOREMAT.06 = weighted.mean(SCOREMAT, DAPOP2006, na.rm = TRUE),
            SCORESOC.06 = weighted.mean(SCORESOC, DAPOP2006, na.rm = TRUE))

# Get Pampalon 2011
pampalon11 <- read.xlsx("data/Canada2011Pampalon/A-MSDIData_Can2011_eng/1. CorrespondenceTable_Can2011_eng.xlsx", sheet = 2) %>%
  mutate(DA = as.character(DA)) %>%
  select(DA, DAPOP2011, SCOREMAT, SCORESOC)

# Get LUT DA2011 <-> DA2016 from StatCan
lut_da <- read.csv("data/2016_92-156_DA_AD_csv/2016_92-156_DA_AD.csv", colClasses = "character") %>%
  select(!c(DBUID2016.IDIDU2016, DA_rel_flag.AD_ind_rel)) %>%
  unique()

# Link Pampalon 2011 to LUT, then to Pampalon 06 and finally compute weighted mean of scores of Pampalon 2011
pampalon11.16 <- pampalon11 %>%
  inner_join(lut_da, by = c("DA" = "DAUID2011.ADIDU2011")) %>%
  left_join(pampalon06.11, by =c("DA" = "DAUID2011.ADIDU2011")) %>%
  group_by(DAUID2016.ADIDU2016) %>%
  summarise(pop2011 = sum(DAPOP2011),
            SCOREMAT = weighted.mean(SCOREMAT, DAPOP2011, na.rm = TRUE),
            SCORESOC = weighted.mean(SCORESOC, DAPOP2011, na.rm = TRUE),
            SCOREMAT.06 = weighted.mean(SCOREMAT.06, pop2006, na.rm = TRUE),
            SCORESOC.06 = weighted.mean(SCORESOC.06, pop2006, na.rm = TRUE),
            pop2006 = sum(pop2006))

# Then link Pampalon 2011 to 2016
pampalon <- pampalon %>%
  left_join(pampalon11.16, by = c("GeoUID" = "DAUID2016.ADIDU2016"), suffix = c(".16", ".11"))

# Aggregate at the CT level
pampalon_CT <- pampalon %>%
  group_by(CT_UID) %>%
  summarise(wSCOREMAT.2016 = weighted.mean(SCOREMAT.16, Population, na.rm = TRUE),
            wSCORESOC.2016 = weighted.mean(SCORESOC.16, Population, na.rm = TRUE),
            wSCOREMAT.2011 = weighted.mean(SCOREMAT.11, pop2011, na.rm = TRUE),
            wSCORESOC.2011 = weighted.mean(SCORESOC.11, pop2011, na.rm = TRUE),
            wSCOREMAT.2006 = weighted.mean(SCOREMAT.06, pop2006, na.rm = TRUE),
            wSCORESOC.2006 = weighted.mean(SCORESOC.06, pop2006, na.rm = TRUE))

# Clean up
rm(lut_da, lut_da.1, pampalon11.16, pampalon06.11, pampalon11, pampalon06)

# Display map
.pampalon_CT_geom <- CT16 %>%
  left_join(pampalon_CT, by = c("GeoUID" = "CT_UID")) %>%
  filter(interact_aoi)

.pampalon_data <- bi_class(.pampalon_CT_geom, x = wSCOREMAT.2016, y = wSCORESOC.2016, style = "quantile", dim = 3)
## Warning in classInt::classIntervals(bins_x, n = dim, style = "quantile"): var
## has missing values, omitted in finding classes
## Warning in classInt::classIntervals(bins_y, n = dim, style = "quantile"): var
## has missing values, omitted in finding classes
.map <- ggplot() + 
  geom_sf(data = .pampalon_data, mapping = aes(fill = bi_class), color = "white", size = 0.1, show.legend = FALSE) +
  bi_scale_fill(pal = "DkBlue", dim = 3) +
  labs(title = "Pampalon: material and social deprivation index") + 
  theme(panel.background = element_rect(fill = "white"),
        #axis.ticks = element_blank(),
        #axis.text = element_blank(),
        panel.grid = element_line(color = "darkgray", size = 0.2))
.legend <- bi_legend(pal = "DkBlue",
                    dim = 3,
                    xlab = "Material ",
                    ylab = "Social ",
                    size = 8)
ggdraw() +
  draw_plot(.map, 0, 0, 1, 1) +
  draw_plot(.legend, 0.1, .7, 0.2, 0.2)

2.4 Gentrification

Using Ding metric computed on 5 year span.

# Load gentrified CTs, 5 year span (from repo gentrification_metrics)
ding <- list()
ding[["2016"]] <- st_read("data/gentrified_5years.gpkg", "gentrified_ding_16", quiet=TRUE) %>%
  filter(cma_uid_16 == "24462") %>%
  st_transform(st_crs(bike_lane))
ding[["2011"]] <- st_read("data/gentrified_5years.gpkg", "gentrified_ding_11", quiet=TRUE) %>%
  filter(cma_uid_11 == "24462") %>%
  st_transform(st_crs(bike_lane))
ding[["2006"]] <- st_read("data/gentrified_5years.gpkg", "gentrified_ding_06", quiet=TRUE) %>%
  filter(cma_uid_06 == "24462") %>%
  st_transform(st_crs(bike_lane))

.ding_map <- ding[["2016"]] %>%
  left_join(select(as.data.frame(CT16), GeoUID, interact_aoi), by = c("ct_uid_16" = "GeoUID")) %>%
  filter(interact_aoi)

ggplot(data = .ding_map) + 
  geom_sf(aes(fill = gentrified_2016_2011, colour=gentrifiable_2011)) +
  scale_fill_manual(values = c("gray", "red", "darkgray"), name = "Gentrified in 2016") +
  scale_colour_manual(values = c("darkgray", "darkred", "darkgray"), name = "Gentrifiable in 2011") +
  labs(title = "Census tract gentrification status in 2016")

2.5 Equity metrics | low-income population and visible minority

Introduced here as a proposition, nothing acted (2022-02-04)

# Visible Minority
# - v_CA16_3954: Total - Visible minority for the population in private households - 25% sample data (Total)
# - v_CA16_3957: Total visible minority population (Total)

# Low income (LIM-AT)
# - v_CA16_2540: Prevalence of low income based on the Low-income measure, after tax (LIM-AT) (%) (Total)
equity_ct16 <- get_census(dataset='CA16', regions=list(CMA='24462'), level='CT', geo_format = "sf",
                          vectors = c("v_CA16_3954", "v_CA16_3957", "v_CA16_2540")) %>%
  filter(Type == "CT") %>%
  transmute(CT_UID = GeoUID,
            vis_minority_2016 = `v_CA16_3957: Total visible minority population` / `v_CA16_3954: Total - Visible minority for the population in private households - 25% sample data` * 100,
            low_income_2016 = `v_CA16_2540: Prevalence of low income based on the Low-income measure, after tax (LIM-AT) (%)`)
## Reading vectors data from local cache.
## Reading geo data from local cache.
# Visible Minority
# - v_CA11N_457: CA 2011 NHS, Total population in private households by visible minority (Total)
# - v_CA11N_460: CA 2011 NHS, Total population in private households by visible minority, Total visible minority population (Total)

# Low income (LIM-AT)
# - v_CA11N_2606: CA 2011 NHS, Prevalence of low income in 2010 based on after-tax low-income measure % (Total)
equity_ct11 <- get_census(dataset='CA11', regions=list(CMA='24462'), level='CT', geo_format = "sf",
                          vectors = c("v_CA11N_457", "v_CA11N_460", "v_CA11N_2606")) %>%
  filter(Type == "CT") %>%
  transmute(CT_UID = GeoUID,
            vis_minority_2011 = `v_CA11N_460: Total visible minority population` / `v_CA11N_457: Total population in private households by visible minority` * 100,
            low_income_2011 = `v_CA11N_2606: Prevalence of low income in 2010 based on after-tax low-income measure %`)
## Reading vectors data from local cache.
## Reading geo data from local cache.
# Visible Minority
# - v_CA06_1302: Total population by visible minority groups
# - v_CA06_1303: Total population by visible minority groups, Total visible minority population

# Low income (LIM-AT)
# - v_TX2006_551: After-tax low income status of tax filers and dependents (census family low income measure, CFLIM-AT) for couple and lone parent families by family composition, 2006 | All family units | Persons in Low Income | % - Total
equity_ct06 <- get_census(dataset='CA06', regions=list(CMA='24462'), level='CT', geo_format = "sf",
                          vectors = c("v_CA06_1302", "v_CA06_1303", "v_TX2006_551")) %>%
  filter(Type == "CT") %>%
  transmute(CT_UID = GeoUID,
            vis_minority_2006 = `v_CA06_1303: Total visible minority population` / `v_CA06_1302: Total population by visible minority groups - 20% sample data` * 100,
            low_income_2006 = `v_TX2006_551: % - Total`)
## Reading vectors data from local cache.
## Reading geo data from local cache.
equity_ct <- st_join(equity_ct16, equity_ct11, left=TRUE, largest=TRUE, suffix=c("", "_2011")) %>% # join on largest overlap, to overcome mismatch in CT UID
  st_join(equity_ct06, left=TRUE, largest=TRUE, suffix=c("", "_2006")) %>%
  data.frame()
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries

## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
# cleanup
rm(equity_ct11, equity_ct16, equity_ct06)

# Display map
.equity_CT_geom <- CT16 %>%
  left_join(equity_ct, by = c("GeoUID" = "CT_UID")) %>%
  filter(interact_aoi)

.equity_data <- bi_class(.equity_CT_geom, x = vis_minority_2016, y = low_income_2016, style = "quantile", dim = 3)
## Warning in classInt::classIntervals(bins_x, n = dim, style = "quantile"): var
## has missing values, omitted in finding classes
## Warning in classInt::classIntervals(bins_y, n = dim, style = "quantile"): var
## has missing values, omitted in finding classes
.map <- ggplot() + 
  geom_sf(data = .equity_data, mapping = aes(fill = bi_class), color = "white", size = 0.1, show.legend = FALSE) +
  bi_scale_fill(pal = "Brown", dim = 3) +
  labs(title = "Equity metrics: % of visible minority and % of low-income household") + 
  theme(panel.background = element_rect(fill = "white"),
        #axis.ticks = element_blank(),
        #axis.text = element_blank(),
        panel.grid = element_line(color = "darkgray", size = 0.2))
.legend <- bi_legend(pal = "Brown",
                    dim = 3,
                    xlab = "Vis. Minority ",
                    ylab = "Low-Income ",
                    size = 8)
ggdraw() +
  draw_plot(.map, 0, 0, 1, 1) +
  draw_plot(.legend, 0.1, .7, 0.2, 0.2)

2.6 Build complete dataset

All variables + outcome linked at the CT level

.bike_lane_changes <- bike_lane_changes %>%
  as.data.frame() %>%
  select(GeoUID, ends_with("ct", ignore.case = FALSE), ends_with("b250", ignore.case = FALSE), ends_with("b500", ignore.case = FALSE), ends_with("b750", ignore.case = FALSE)) %>%
  select(GeoUID, starts_with("Bike_lane")) # Drop individual category lane length

bei_df <- CT16 %>%
  as.data.frame() %>%
  transmute(CT_UID = GeoUID,
            CD_UID = CD_UID,
            CSD_UID = CSD_UID,
            interact_aoi = interact_aoi,
            Population = Population) %>%
  left_join(pampalon_CT, by="CT_UID") %>%
  left_join(select(as.data.frame(ding$`2016`), ct_uid_16, starts_with("gentrif")), by=c("CT_UID" = "ct_uid_16")) %>%
  left_join(select(as.data.frame(ding$`2011`), ct_uid_11, starts_with("gentrif")), by=c("CT_UID" = "ct_uid_11")) %>%
  left_join(select(as.data.frame(ding$`2006`), ct_uid_06, starts_with("gentrif")), by=c("CT_UID" = "ct_uid_06")) %>%
  left_join(select(as.data.frame(equity_ct), !c("geometry", "CT_UID_2011", "CT_UID_2006")), by="CT_UID") %>%
  left_join(.bike_lane_changes, by=c("CT_UID" = "GeoUID")) %>%
  left_join(as.data.frame(esp_vert_ct), by=c("CT_UID" = "GeoUID")) %>%
  left_join(as.data.frame(esp_vert_buf250), by=c("CT_UID" = "GeoUID"), suffix=c("ct", "b250")) %>%
  left_join(as.data.frame(esp_vert_buf500), by=c("CT_UID" = "GeoUID")) %>%
  left_join(as.data.frame(esp_vert_buf750), by=c("CT_UID" = "GeoUID"), suffix=c("b500", "b750"))
  
  
head(bei_df)
write.csv(bei_df, "data/_results/bei_equity.csv", na="", row.names = FALSE)

Included variables:

  • Census Tracts variables
    • CT_UID: 2016 Census Tract ID
    • CD_UID: 2016 Census Division
    • CSD_UID: 2016 Census Subdivision
    • interact_aoi: Does CT belong to INTERACT study area?
    • Population: 2016 Population within CT
    • ct_area_m2.{ct|b{250|500|750}}: Area of CT or buffer of 250, 500 or 750m radius around CT, in square meters
  • Gentrification metrics
    • gentrified_2016_2011: Is the CT gentrified in 2016?
    • gentrifiable_2011: Is the CT candidate to gentrification in 2011?
    • gentrified_2011_2006: Is the CT gentrified in 2011
    • gentrifiable_2006: Is the CT candidate to gentrification in 2006
    • gentrified_2006_2001: Is the CT gentrified in 2006
    • gentrifiable_2001: Is the CT candidate to gentrification in 2001
  • Pampalon’s metrics
    • wSCOREMAT.2016: Social deprivation index in 2016 (population weighted)
    • wSCORESOC.2016: Material deprivation index in 2016 (population weighted)
    • wSCOREMAT.2011: Social deprivation index in 2011 (population weighted)
    • wSCORESOC.2011: Material deprivation index in 2011 (population weighted)
    • wSCOREMAT.2006: Social deprivation index in 2006 (population weighted)
    • wSCORESOC.2006: Material deprivation index in 2006 (population weighted)
  • Social profile
    • vis_minority_2016: % of visible minority in CT 2016
    • low_income_2016: prevalence of low income in CT 2016
    • vis_minority_2011: % of visible minority in CT 2011
    • low_income_2011: prevalence of low income in CT 2011
    • vis_minority_2006: % of visible minority in CT 2006
    • low_income_2006: prevalence of low income in CT 2006
  • Bike lane density
    • Bike_lane_total.{2016|2011}{ct|b{250|500|750}}: total length of bike lanes, in 2016 or 2011, within CT or buffer of 250, 500 or 750m radius
    • Bike_lane.by.street.{2016|2011}{ct|b{250|500|750}}: % of bike lanes compared to streets, in 2016 or 2011, within CT or buffer of 250, 500 or 750m radius
    • Bike_lane_diff.2011.2016{ct|b{250|500|750}}: change in total length of bike lanes between 2011 and 2011, within CT or buffer of 250, 500 or 750m radius
    • Bike_lane_diff.by.street.2011.2016{ct|b{250|500|750}}: change in total length of bike lanes between 2011 and 2011, normalized by street length, within CT or buffer of 250, 500 or 750m radius
    • Bike_lane_diff.by.area.2011.2016{ct|b{250|500|750}}: change in total length of bike lanes between 2011 and 2011, normalized by area, within CT or buffer of 250, 500 or 750m radius
  • Green spaces
    • pct_esp_vert_{2011|2015|2019}.{ct|b{250|500|750}}: % of green space in 2011, 2015 or 2019 within CT or buffer of 250, 500 or 750m radius
    • pct_esp_vert_{low|high}_{2011|2015|2019}.{ct|b{250|500|750}}: same as above, except for grass (low) and tree (high)
    • pct_esp_vert_diff{2011|2015}.{2015|2019}.{ct|b{250|500|750}}: change in % of green space between 2011 and 2015, 2011 and 2019 as well as 2011 and 2019, within CT or buffer of 250, 500 or 750m radius

3 Preliminary analyses

3.1 INTERACT study area

INTERACT study area ~ Montréal, Laval, Longueuil, Brossard, St-Lambert

3.1.1 SES variable distribution

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, starts_with("wSCORE")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_histogram() + 
  facet_wrap(~name) #, scales = "free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 86 rows containing non-finite values (stat_bin).

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, starts_with("vis_minority"), starts_with("low_income")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_histogram() + 
  facet_wrap(~name) #, scales = "free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 85 rows containing non-finite values (stat_bin).

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, starts_with("gentrif")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_bar() + 
  facet_wrap(~name) #, scales = "free", ncol = 3)

# Testing correlation between numeric variables
corrplot::corrplot(cor(select(bei_df, starts_with("wSCORE"), starts_with("vis_"), starts_with("low_")), use = "complete.obs"), type="upper", order="hclust")

# ANOVA for gentrified variables (see https://stats.stackexchange.com/questions/119835/correlation-between-a-nominal-iv-and-a-continuous-dv-variable)
heplots::etasq(aov(gentrified_2016_2011 ~ wSCOREMAT.2011, data = bei_df))
heplots::etasq(aov(gentrified_2016_2011 ~ low_income_2011, data = bei_df))
heplots::etasq(aov(gentrified_2016_2011 ~ vis_minority_2011, data = bei_df))

3.1.2 BEI variable distributions

3.1.2.1 Census Tracts

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, matches("^Bike_lane.*ct$"), matches("^pct_esp_vert_diff.*ct$")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_histogram() + 
  facet_wrap(~name, scales = "free", ncol = 3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

3.1.2.2 Buffers 250m

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, matches("^Bike_lane.*b250$"), matches("^pct_esp_vert_diff.*b250$")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_histogram() + 
  facet_wrap(~name, scales = "free", ncol = 3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

3.1.2.3 Buffers 500m

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, matches("^Bike_lane.*b500$"), matches("^pct_esp_vert_diff.*b500$")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_histogram() + 
  facet_wrap(~name, scales = "free", ncol = 3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

3.1.2.4 Buffers 750m

.bei_df_long <- bei_df %>% 
  filter(interact_aoi) %>%
  units::drop_units() %>% 
  select(CT_UID, CD_UID, matches("^Bike_lane.*b750$"), matches("^pct_esp_vert_diff.*b750$")) %>%
  pivot_longer(!c(CT_UID, CD_UID))

ggplot(.bei_df_long, aes(value)) +
  geom_histogram() + 
  facet_wrap(~name, scales = "free", ncol = 3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

4 Association between SES and Urban Conditions at baseline (2011)

Looking at objective #1 | do urban interventions tend to be located in low SES neighborhoods?. We look at \[Urban Condition_{2011} = f(SES_{2011})\] as well as \[Urban Condition_{2011} = f(Gentrification_{2011 \to 2016})\]

Here \(UrbanCondition\) means the state of the urban environment features, such as length of bike lanes, greenness coverage, etc. This needs to be distinguished from \(UrbanIntervention\), which accounts for the changes in the \(UrbanConditions\) (see below).

4.1 INTERACT study area

# keep only interact CT
bei_df_aoi <- filter(bei_df, interact_aoi)

4.1.1 UC vs Pampalon | material

4.1.1.1 Bike lane length

Bike lane ratio to streets (in %)

4.1.1.1.1 Census tract level
f <- Bike_lane.by.street.2011ct ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011ct, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.246  -7.693  -2.062   5.092  59.301 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      8.8919     0.3618  24.580  < 2e-16 ***
## wSCOREMAT.2011 -27.4813     8.8278  -3.113  0.00193 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.408 on 686 degrees of freedom
## Multiple R-squared:  0.01393,    Adjusted R-squared:  0.01249 
## F-statistic: 9.691 on 1 and 686 DF,  p-value: 0.001929
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 10.246, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.2337904947    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 101.77, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 106.16, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 2.9791, df = 1, p-value = 0.08435
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 7.3656, df = 1, p-value = 0.006648
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 109.14, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ====================================================================
##                                   Dependent variable:               
##                     ------------------------------------------------
##                                Bike_lane.by.street.2011ct           
##                              OLS              spatial      spatial  
##                                            autoregressive   error   
##                              (1)                (2)          (3)    
## --------------------------------------------------------------------
## wSCOREMAT.2011            -27.481***          -15.018*     -13.245  
##                            (8.828)            (8.129)      (10.422) 
##                                                                     
## Constant                   8.892***           4.768***     8.897*** 
##                            (0.362)            (0.529)      (0.625)  
##                                                                     
## --------------------------------------------------------------------
## Observations                 688                688          688    
## R2                          0.014                                   
## Adjusted R2                 0.012                                   
## Log Likelihood                               -2,474.959   -2,475.859
## sigma2                                         74.536       74.706  
## Akaike Inf. Crit.                            4,957.919    4,959.717 
## Residual Std. Error    9.408 (df = 686)                             
## F Statistic         9.691*** (df = 1; 686)                          
## Wald Test (df = 1)                           102.747***   103.290***
## LR Test (df = 1)                             84.961***    83.162*** 
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
4.1.1.1.2 Buffers 250m
f <- Bike_lane.by.street.2011b250 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b250, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -12.4924  -5.3065  -0.8788   3.8680  24.9469 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      8.9172     0.2547  35.008  < 2e-16 ***
## wSCOREMAT.2011 -33.8663     6.2159  -5.448 7.09e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.625 on 686 degrees of freedom
## Multiple R-squared:  0.04148,    Adjusted R-squared:  0.04008 
## F-statistic: 29.68 on 1 and 686 DF,  p-value: 7.093e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 22.121, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5073557016    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 479.3, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 479.25, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 3.436, df = 1, p-value = 0.06379
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 3.3902, df = 1, p-value = 0.06558
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 482.69, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                               Bike_lane.by.street.2011b250           
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## wSCOREMAT.2011            -33.866***          -15.010***   -23.429***
##                             (6.216)            (4.436)      (6.292)  
##                                                                      
## Constant                   8.917***            2.182***     9.474*** 
##                             (0.255)            (0.311)      (0.815)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.041                                   
## Adjusted R2                  0.040                                   
## Log Likelihood                                -2,087.005   -2,085.916
## sigma2                                          21.637       21.458  
## Akaike Inf. Crit.                             4,182.010    4,179.832 
## Residual Std. Error    6.625 (df = 686)                              
## F Statistic         29.685*** (df = 1; 686)                          
## Wald Test (df = 1)                            831.117***   873.206***
## LR Test (df = 1)                              378.175***   380.353***
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
4.1.1.1.3 Buffers 500m
f <- Bike_lane.by.street.2011b500 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b500, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.7541  -3.9158  -0.7623   3.1286  20.7276 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      8.9616     0.2165  41.390  < 2e-16 ***
## wSCOREMAT.2011 -30.9568     5.2836  -5.859 7.23e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.631 on 686 degrees of freedom
## Multiple R-squared:  0.04766,    Adjusted R-squared:  0.04627 
## F-statistic: 34.33 on 1 and 686 DF,  p-value: 7.228e-09
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 27.057, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6210550039    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 718.19, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 719.84, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 5.1153, df = 1, p-value = 0.02372
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 6.7583, df = 1, p-value = 0.009331
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 724.95, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                Bike_lane.by.street.2011b500            
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## wSCOREMAT.2011            -30.957***          -11.036***    -16.818*** 
##                             (5.284)            (3.132)       (4.507)   
##                                                                        
## Constant                   8.962***            1.412***      9.885***  
##                             (0.217)            (0.229)       (0.944)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.048                                     
## Adjusted R2                  0.046                                     
## Log Likelihood                                -1,865.242    -1,864.648 
## sigma2                                          10.717        10.632   
## Akaike Inf. Crit.                             3,738.484     3,737.297  
## Residual Std. Error    5.631 (df = 686)                                
## F Statistic         34.328*** (df = 1; 686)                            
## Wald Test (df = 1)                           1,987.554***  2,101.754***
## LR Test (df = 1)                              598.105***    599.292*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.1.1.4 Buffers 750m
f <- Bike_lane.by.street.2011b750 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b750, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.4973  -3.5621  -0.5177   2.3924  18.4090 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      8.9833     0.1942  46.248  < 2e-16 ***
## wSCOREMAT.2011 -26.4397     4.7401  -5.578  3.5e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.052 on 686 degrees of freedom
## Multiple R-squared:  0.04339,    Adjusted R-squared:  0.04199 
## F-statistic: 31.11 on 1 and 686 DF,  p-value: 3.504e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 30.115, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6915177665    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 890.41, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 897.95, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 3.4296, df = 1, p-value = 0.06404
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 10.977, df = 1, p-value = 0.0009222
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 901.38, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                Bike_lane.by.street.2011b750            
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## wSCOREMAT.2011            -26.440***          -7.029***      -8.978**  
##                             (4.740)            (2.392)       (3.491)   
##                                                                        
## Constant                   8.983***            1.003***     10.187***  
##                             (0.194)            (0.181)       (1.048)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.043                                     
## Adjusted R2                  0.042                                     
## Log Likelihood                                -1,697.058    -1,698.113 
## sigma2                                          6.321         6.310    
## Akaike Inf. Crit.                             3,402.115     3,404.227  
## Residual Std. Error    5.052 (df = 686)                                
## F Statistic         31.113*** (df = 1; 686)                            
## Wald Test (df = 1)                           3,630.643***  3,815.502***
## LR Test (df = 1)                              785.093***    782.981*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

4.1.1.2 Canopy

Measuring canopy (i.e. greenness ~ grass & trees) ratio within CT/buffer in 2011 (in %)

4.1.1.2.1 Census tract level
f <- pct_esp_vert_2011ct ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011ct, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -48.391 -11.625  -0.412   8.963  47.761 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      37.8835     0.5933  63.853  < 2e-16 ***
## wSCOREMAT.2011 -107.0035    14.4780  -7.391 4.26e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.43 on 686 degrees of freedom
## Multiple R-squared:  0.07375,    Adjusted R-squared:  0.0724 
## F-statistic: 54.62 on 1 and 686 DF,  p-value: 4.259e-13
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 29.503, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6774003651    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 854.42, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 813.13, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 41.317, df = 1, p-value = 1.294e-10
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 0.02066, df = 1, p-value = 0.8857
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 854.44, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                                    pct_esp_vert_2011ct               
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## wSCOREMAT.2011            -107.004***         -55.727***   -93.994***
##                            (14.478)            (9.376)      (12.779) 
##                                                                      
## Constant                   37.884***           8.352***    37.913*** 
##                             (0.593)            (1.026)      (1.761)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.074                                   
## Adjusted R2                  0.072                                   
## Log Likelihood                                -2,581.237   -2,573.896
## sigma2                                          90.493       87.923  
## Akaike Inf. Crit.                             5,170.475    5,155.792 
## Residual Std. Error    15.430 (df = 686)                             
## F Statistic         54.624*** (df = 1; 686)                          
## Wald Test (df = 1)                            964.910***   986.469***
## LR Test (df = 1)                              553.147***   567.830***
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
4.1.1.2.2 Buffer 250m
f <- pct_esp_vert_2011b250 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b250, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -41.994  -8.249  -0.962   7.172  41.278 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     36.0938     0.4913  73.472  < 2e-16 ***
## wSCOREMAT.2011 -90.8944    11.9881  -7.582 1.11e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.78 on 686 degrees of freedom
## Multiple R-squared:  0.07732,    Adjusted R-squared:  0.07598 
## F-statistic: 57.49 on 1 and 686 DF,  p-value: 1.108e-13
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 33.785, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7760610807    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1121.4, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1082.1, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 41.13, df = 1, p-value = 1.425e-10
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 1.7731, df = 1, p-value = 0.183
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1123.2, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                    pct_esp_vert_2011b250               
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## wSCOREMAT.2011            -90.894***          -35.840***    -58.463*** 
##                            (11.988)            (6.115)       (8.473)   
##                                                                        
## Constant                   36.094***           4.819***     35.341***  
##                             (0.491)            (0.682)       (1.904)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.077                                     
## Adjusted R2                  0.076                                     
## Log Likelihood                                -2,305.440    -2,300.649 
## sigma2                                          38.309        37.471   
## Akaike Inf. Crit.                             4,618.880     4,609.298  
## Residual Std. Error    12.776 (df = 686)                               
## F Statistic         57.488*** (df = 1; 686)                            
## Wald Test (df = 1)                           2,333.078***  2,367.374***
## LR Test (df = 1)                              845.068***    854.649*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.1.2.3 Buffer 500m
f <- pct_esp_vert_2011b500 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b500, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -40.840  -8.069  -0.956   7.133  40.589 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     36.1297     0.4658  77.562  < 2e-16 ***
## wSCOREMAT.2011 -82.6144    11.3673  -7.268 9.98e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.11 on 686 degrees of freedom
## Multiple R-squared:  0.07149,    Adjusted R-squared:  0.07014 
## F-statistic: 52.82 on 1 and 686 DF,  p-value: 9.98e-13
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 35.083, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8059637223    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1209.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1182.9, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 31.277, df = 1, p-value = 2.237e-08
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 4.6284, df = 1, p-value = 0.03145
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1214.1, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                    pct_esp_vert_2011b500               
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## wSCOREMAT.2011            -82.614***          -26.263***    -40.243*** 
##                            (11.367)            (5.043)       (7.118)   
##                                                                        
## Constant                   36.130***           3.539***     34.662***  
##                             (0.466)            (0.554)       (2.142)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.071                                     
## Adjusted R2                  0.070                                     
## Log Likelihood                                -2,189.690    -2,188.260 
## sigma2                                          26.537        26.226   
## Akaike Inf. Crit.                             4,387.381     4,384.520  
## Residual Std. Error    12.115 (df = 686)                               
## F Statistic         52.820*** (df = 1; 686)                            
## Wald Test (df = 1)                           3,727.412***  3,828.719***
## LR Test (df = 1)                             1,003.406***  1,006.267***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.1.2.4 Buffer 750m
f <- pct_esp_vert_2011b750 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b750, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -38.407  -8.278  -0.885   7.320  39.901 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     36.1774     0.4519  80.049  < 2e-16 ***
## wSCOREMAT.2011 -75.0110    11.0286  -6.801 2.26e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.75 on 686 degrees of freedom
## Multiple R-squared:  0.06317,    Adjusted R-squared:  0.06181 
## F-statistic: 46.26 on 1 and 686 DF,  p-value: 2.256e-11
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 36.177, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8311578261    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1286.3, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1271, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 22.775, df = 1, p-value = 1.821e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 7.4647, df = 1, p-value = 0.006292
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1293.8, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                    pct_esp_vert_2011b750               
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## wSCOREMAT.2011            -75.011***          -19.087***    -27.008*** 
##                            (11.029)            (4.289)       (6.153)   
##                                                                        
## Constant                   36.177***           2.652***     33.624***  
##                             (0.452)            (0.456)       (2.395)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.063                                     
## Adjusted R2                  0.062                                     
## Log Likelihood                                -2,094.042    -2,094.742 
## sigma2                                          19.608        19.516   
## Akaike Inf. Crit.                             4,196.083     4,197.484  
## Residual Std. Error    11.754 (df = 686)                               
## F Statistic         46.260*** (df = 1; 686)                            
## Wald Test (df = 1)                           5,540.608***  5,769.353***
## LR Test (df = 1)                             1,153.082***  1,151.681***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

4.1.1.3 Canopy (trees)

Measuring high canopy (i.e. trees only) ratio within CT/buffer in 2011 (in %)

4.1.1.3.1 Census tract level
f <- pct_esp_vert_high_2011ct ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011ct, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -29.577  -5.434  -0.814   4.543  44.870 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     18.7420     0.3367   55.66   <2e-16 ***
## wSCOREMAT.2011 -94.8192     8.2173  -11.54   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.758 on 686 degrees of freedom
## Multiple R-squared:  0.1625, Adjusted R-squared:  0.1613 
## F-statistic: 133.1 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 16.926, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3876814605    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 279.85, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 266.08, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 16.623, df = 1, p-value = 4.559e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 2.8535, df = 1, p-value = 0.09117
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 282.71, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ======================================================================
##                                    Dependent variable:                
##                     --------------------------------------------------
##                                  pct_esp_vert_high_2011ct             
##                               OLS               spatial      spatial  
##                                              autoregressive   error   
##                               (1)                 (2)          (3)    
## ----------------------------------------------------------------------
## wSCOREMAT.2011             -94.819***          -56.572***   -77.426***
##                             (8.217)             (7.279)      (9.323)  
##                                                                       
## Constant                   18.742***            7.465***    18.814*** 
##                             (0.337)             (0.739)      (0.751)  
##                                                                       
## ----------------------------------------------------------------------
## Observations                  688                 688          688    
## R2                           0.163                                    
## Adjusted R2                  0.161                                    
## Log Likelihood                                 -2,367.141   -2,366.119
## sigma2                                           52.440       51.863  
## Akaike Inf. Crit.                              4,742.281    4,740.238 
## Residual Std. Error     8.758 (df = 686)                              
## F Statistic         133.147*** (df = 1; 686)                          
## Wald Test (df = 1)                             279.416***   290.922***
## LR Test (df = 1)                               201.998***   204.042***
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01
4.1.1.3.2 Buffer 250m
f <- pct_esp_vert_high_2011b250 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b250, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -25.863  -4.293  -0.858   3.468  27.899 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     17.6469     0.2676   65.95   <2e-16 ***
## wSCOREMAT.2011 -81.4809     6.5295  -12.48   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.959 on 686 degrees of freedom
## Multiple R-squared:  0.185,  Adjusted R-squared:  0.1838 
## F-statistic: 155.7 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 22.625, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5189565162    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 501.47, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 491.77, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 22.702, df = 1, p-value = 1.892e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 13, df = 1, p-value = 0.0003115
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 514.47, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ======================================================================
##                                    Dependent variable:                
##                     --------------------------------------------------
##                                 pct_esp_vert_high_2011b250            
##                               OLS               spatial      spatial  
##                                              autoregressive   error   
##                               (1)                 (2)          (3)    
## ----------------------------------------------------------------------
## wSCOREMAT.2011             -81.481***          -35.502***   -47.765***
##                             (6.530)             (4.833)      (6.499)  
##                                                                       
## Constant                   17.647***            4.184***    17.578*** 
##                             (0.268)             (0.492)      (0.887)  
##                                                                       
## ----------------------------------------------------------------------
## Observations                  688                 688          688    
## R2                           0.185                                    
## Adjusted R2                  0.184                                    
## Log Likelihood                                 -2,106.447   -2,108.671
## sigma2                                           22.962       22.766  
## Akaike Inf. Crit.                              4,220.895    4,225.343 
## Residual Std. Error     6.959 (df = 686)                              
## F Statistic         155.721*** (df = 1; 686)                          
## Wald Test (df = 1)                             885.065***   968.739***
## LR Test (df = 1)                               407.027***   402.579***
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01
4.1.1.3.3 Buffer 500m
f <- pct_esp_vert_high_2011b500 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b500, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -25.3606  -4.0634  -0.9925   3.5717  26.5359 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     17.7227     0.2506   70.72   <2e-16 ***
## wSCOREMAT.2011 -76.3607     6.1150  -12.49   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.517 on 686 degrees of freedom
## Multiple R-squared:  0.1852, Adjusted R-squared:  0.184 
## F-statistic: 155.9 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 25.515, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5855426655    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 638.41, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 641.08, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 21.276, df = 1, p-value = 3.977e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 23.949, df = 1, p-value = 9.894e-07
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 662.36, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                     Dependent variable:                 
##                     ----------------------------------------------------
##                                  pct_esp_vert_high_2011b500             
##                               OLS               spatial       spatial   
##                                              autoregressive    error    
##                               (1)                 (2)           (3)     
## ------------------------------------------------------------------------
## wSCOREMAT.2011             -76.361***          -26.616***    -33.870*** 
##                             (6.115)             (3.921)       (5.388)   
##                                                                         
## Constant                   17.723***            2.929***     17.592***  
##                             (0.251)             (0.389)       (1.089)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                  688                 688           688     
## R2                           0.185                                      
## Adjusted R2                  0.184                                      
## Log Likelihood                                 -1,982.040    -1,986.620 
## sigma2                                           15.295        15.219   
## Akaike Inf. Crit.                              3,972.079     3,981.239  
## Residual Std. Error     6.517 (df = 686)                                
## F Statistic         155.936*** (df = 1; 686)                            
## Wald Test (df = 1)                            1,721.994***  1,976.463***
## LR Test (df = 1)                               565.594***    556.433*** 
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
4.1.1.3.4 Buffer 750m
f <- pct_esp_vert_high_2011b750 ~ wSCOREMAT.2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b750, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -24.5142  -3.8942  -0.6622   3.4979  25.5458 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      17.732      0.238   74.50   <2e-16 ***
## wSCOREMAT.2011  -72.183      5.808  -12.43   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.19 on 686 degrees of freedom
## Multiple R-squared:  0.1838, Adjusted R-squared:  0.1826 
## F-statistic: 154.4 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 27.314, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6269833160    -0.0022565434     0.0005307145
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 731.97, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 750.57, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 17.474, df = 1, p-value = 2.912e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 36.078, df = 1, p-value = 1.896e-09
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 768.05, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                     Dependent variable:                 
##                     ----------------------------------------------------
##                                  pct_esp_vert_high_2011b750             
##                               OLS               spatial       spatial   
##                                              autoregressive    error    
##                               (1)                 (2)           (3)     
## ------------------------------------------------------------------------
## wSCOREMAT.2011             -72.183***          -20.618***    -23.666*** 
##                             (5.808)             (3.304)       (4.614)   
##                                                                         
## Constant                   17.732***            2.187***     17.400***  
##                             (0.238)             (0.320)       (1.269)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                  688                 688           688     
## R2                           0.184                                      
## Adjusted R2                  0.183                                      
## Log Likelihood                                 -1,880.764    -1,887.687 
## sigma2                                           11.035        11.044   
## Akaike Inf. Crit.                              3,769.528     3,783.374  
## Residual Std. Error     6.190 (df = 686)                                
## F Statistic         154.438*** (df = 1; 686)                            
## Wald Test (df = 1)                            2,782.440***  3,309.059***
## LR Test (df = 1)                               697.370***    683.524*** 
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01

4.1.2 UC vs Visible minority

4.1.2.1 Bike lane length

Bike lane ratio to streets (in %)

4.1.2.1.1 Census tract level
f <- Bike_lane.by.street.2011ct ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011ct, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.724  -7.451  -2.017   4.794  59.709 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       11.09214    0.66670   16.64  < 2e-16 ***
## vis_minority_2011 -0.09297    0.02198   -4.23 2.66e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.289 on 686 degrees of freedom
## Multiple R-squared:  0.02542,    Adjusted R-squared:  0.024 
## F-statistic: 17.89 on 1 and 686 DF,  p-value: 2.658e-05
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 10.099, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.2302335516    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 98.763, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 104.75, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 3.6656, df = 1, p-value = 0.05555
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 9.6516, df = 1, p-value = 0.001892
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 108.41, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                                Bike_lane.by.street.2011ct            
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## vis_minority_2011          -0.093***          -0.053***     -0.055** 
##                             (0.022)            (0.020)      (0.027)  
##                                                                      
## Constant                   11.092***           5.997***    10.163*** 
##                             (0.667)            (0.772)      (0.932)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.025                                   
## Adjusted R2                  0.024                                   
## Log Likelihood                                -2,466.348   -2,467.689
## sigma2                                          72.684       72.942  
## Akaike Inf. Crit.                             4,940.696    4,943.377 
## Residual Std. Error    9.289 (df = 686)                              
## F Statistic         17.890*** (df = 1; 686)                          
## Wald Test (df = 1)                            103.390***   103.613***
## LR Test (df = 1)                              84.661***    81.979*** 
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
4.1.2.1.2 Buffers 250m
f <- Bike_lane.by.street.2011b250 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b250, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.1283  -4.7702  -0.6826   3.8031  22.6845 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       11.56776    0.46466  24.895  < 2e-16 ***
## vis_minority_2011 -0.11104    0.01532  -7.249 1.14e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.474 on 686 degrees of freedom
## Multiple R-squared:  0.07114,    Adjusted R-squared:  0.06979 
## F-statistic: 52.54 on 1 and 686 DF,  p-value: 1.138e-12
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 21.479, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.4923094026    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 451.58, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 465.28, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.31762, df = 1, p-value = 0.573
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 14.02, df = 1, p-value = 0.0001809
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 465.6, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                               Bike_lane.by.street.2011b250           
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## vis_minority_2011          -0.111***          -0.041***    -0.058*** 
##                             (0.015)            (0.011)      (0.017)  
##                                                                      
## Constant                   11.568***           3.143***    10.743*** 
##                             (0.465)            (0.449)      (0.921)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.071                                   
## Adjusted R2                  0.070                                   
## Log Likelihood                                -2,073.739   -2,074.993
## sigma2                                          20.831       20.770  
## Akaike Inf. Crit.                             4,155.477    4,157.985 
## Residual Std. Error    6.474 (df = 686)                              
## F Statistic         52.541*** (df = 1; 686)                          
## Wald Test (df = 1)                            824.596***   883.254***
## LR Test (df = 1)                              373.115***   370.607***
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
4.1.2.1.3 Buffers 500m
f <- Bike_lane.by.street.2011b500 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b500, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.6383  -3.7395  -0.6158   3.0313  20.5416 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       11.48306    0.39258  29.250  < 2e-16 ***
## vis_minority_2011 -0.10529    0.01294  -8.135 1.94e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.47 on 686 degrees of freedom
## Multiple R-squared:  0.08798,    Adjusted R-squared:  0.08665 
## F-statistic: 66.18 on 1 and 686 DF,  p-value: 1.935e-15
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 26.067, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5979778872    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 666.23, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 689.6, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.88198, df = 1, p-value = 0.3477
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 24.253, df = 1, p-value = 8.446e-07
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 690.49, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                Bike_lane.by.street.2011b500            
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.105***          -0.028***     -0.035***  
##                             (0.013)            (0.008)       (0.012)   
##                                                                        
## Constant                   11.483***           2.073***     10.631***  
##                             (0.393)            (0.326)       (0.989)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.088                                     
## Adjusted R2                  0.087                                     
## Log Likelihood                                -1,852.384    -1,854.566 
## sigma2                                          10.345        10.321   
## Akaike Inf. Crit.                             3,712.769     3,717.131  
## Residual Std. Error    5.470 (df = 686)                                
## F Statistic         66.176*** (df = 1; 686)                            
## Wald Test (df = 1)                           1,917.424***  2,114.595***
## LR Test (df = 1)                              583.861***    579.499*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.2.1.4 Buffers 750m
f <- Bike_lane.by.street.2011b750 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b750, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.5951  -3.3767  -0.4199   2.5173  17.7667 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       11.39755    0.35033  32.534   <2e-16 ***
## vis_minority_2011 -0.10001    0.01155  -8.659   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.881 on 686 degrees of freedom
## Multiple R-squared:  0.09854,    Adjusted R-squared:  0.09722 
## F-statistic: 74.98 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 28.753, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6598287150    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 811.18, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 844.99, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.97787, df = 1, p-value = 0.3227
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 34.79, df = 1, p-value = 3.672e-09
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 845.97, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                Bike_lane.by.street.2011b750            
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.100***          -0.019***      -0.020**  
##                             (0.012)            (0.006)       (0.010)   
##                                                                        
## Constant                   11.398***           1.486***     10.613***  
##                             (0.350)            (0.255)       (1.070)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.099                                     
## Adjusted R2                  0.097                                     
## Log Likelihood                                -1,687.994    -1,690.724 
## sigma2                                          6.183         6.174    
## Akaike Inf. Crit.                             3,383.988     3,389.448  
## Residual Std. Error    4.881 (df = 686)                                
## F Statistic         74.984*** (df = 1; 686)                            
## Wald Test (df = 1)                           3,393.522***  3,826.666***
## LR Test (df = 1)                              755.951***    750.492*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

4.1.2.2 Canopy

Measuring canopy (i.e. greenness ~ grass & trees) ratio within CT/buffer in 2011 (in %)

4.1.2.2.1 Census tract level
f <- pct_esp_vert_2011ct ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011ct, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -32.301 -12.257  -0.982   9.551  50.579 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       42.76950    1.12646  37.968  < 2e-16 ***
## vis_minority_2011 -0.21444    0.03714  -5.774 1.17e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.7 on 686 degrees of freedom
## Multiple R-squared:  0.04635,    Adjusted R-squared:  0.04496 
## F-statistic: 33.34 on 1 and 686 DF,  p-value: 1.171e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 29.687, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6813411841    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 864.94, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 840.45, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 24.559, df = 1, p-value = 7.208e-07
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 0.066641, df = 1, p-value = 0.7963
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 865, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                     pct_esp_vert_2011ct                
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.214***          -0.113***     -0.210***  
##                             (0.037)            (0.024)       (0.036)   
##                                                                        
## Constant                   42.769***          10.656***     42.815***  
##                             (1.126)            (1.297)       (2.024)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.046                                     
## Adjusted R2                  0.045                                     
## Log Likelihood                                -2,586.673    -2,581.942 
## sigma2                                          91.496        89.891   
## Akaike Inf. Crit.                             5,181.345     5,171.884  
## Residual Std. Error    15.695 (df = 686)                               
## F Statistic         33.342*** (df = 1; 686)                            
## Wald Test (df = 1)                            998.494***   1,004.093***
## LR Test (df = 1)                              565.726***    575.187*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.2.2.2 Buffer 250m
f <- pct_esp_vert_2011b250 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b250, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.186  -9.367  -1.107   7.568  44.699 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       39.79466    0.93880   42.39  < 2e-16 ***
## vis_minority_2011 -0.16404    0.03095   -5.30 1.56e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.08 on 686 degrees of freedom
## Multiple R-squared:  0.03934,    Adjusted R-squared:  0.03794 
## F-statistic: 28.09 on 1 and 686 DF,  p-value: 1.563e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 34.045, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7817057950    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1138.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1119, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 19.779, df = 1, p-value = 8.694e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 0.26896, df = 1, p-value = 0.604
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1138.8, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                    pct_esp_vert_2011b250               
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.164***          -0.065***     -0.120***  
##                             (0.031)            (0.015)       (0.024)   
##                                                                        
## Constant                   39.795***           5.993***     38.165***  
##                             (0.939)            (0.843)       (2.071)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.039                                     
## Adjusted R2                  0.038                                     
## Log Likelihood                                -2,311.429    -2,308.765 
## sigma2                                          38.689        38.260   
## Akaike Inf. Crit.                             4,630.859     4,625.530  
## Residual Std. Error    13.080 (df = 686)                               
## F Statistic         28.090*** (df = 1; 686)                            
## Wald Test (df = 1)                           2,471.948***  2,468.082***
## LR Test (df = 1)                              865.459***    870.788*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.2.2.3 Buffer 500m
f <- pct_esp_vert_2011b500 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b500, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.853  -9.288  -1.130   7.529  41.846 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       39.18448    0.89156  43.951  < 2e-16 ***
## vis_minority_2011 -0.13715    0.02939  -4.666 3.69e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.42 on 686 degrees of freedom
## Multiple R-squared:  0.03076,    Adjusted R-squared:  0.02935 
## F-statistic: 21.77 on 1 and 686 DF,  p-value: 3.689e-06
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 35.531, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8159225594    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1240.4, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1227.1, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 13.983, df = 1, p-value = 0.0001845
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 0.70087, df = 1, p-value = 0.4025
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1241.1, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                    pct_esp_vert_2011b500               
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.137***          -0.044***     -0.078***  
##                             (0.029)            (0.012)       (0.020)   
##                                                                        
## Constant                   39.184***           4.265***     36.521***  
##                             (0.892)            (0.673)       (2.280)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.031                                     
## Adjusted R2                  0.029                                     
## Log Likelihood                                -2,193.690    -2,192.627 
## sigma2                                          26.637        26.485   
## Akaike Inf. Crit.                             4,395.381     4,393.254  
## Residual Std. Error    12.422 (df = 686)                               
## F Statistic         21.774*** (df = 1; 686)                            
## Wald Test (df = 1)                           4,001.000***  4,012.606***
## LR Test (df = 1)                             1,029.889***  1,032.016***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.2.2.4 Buffer 750m
f <- pct_esp_vert_2011b750 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b750, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.889  -9.175  -0.930   7.561  40.317 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        38.7705     0.8645  44.849  < 2e-16 ***
## vis_minority_2011  -0.1178     0.0285  -4.132 4.04e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.04 on 686 degrees of freedom
## Multiple R-squared:  0.02429,    Adjusted R-squared:  0.02286 
## F-statistic: 17.08 on 1 and 686 DF,  p-value: 4.036e-05
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 36.719, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8432689085    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1324.9, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1316.4, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 9.6956, df = 1, p-value = 0.001847
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 1.1734, df = 1, p-value = 0.2787
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1326.1, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                    pct_esp_vert_2011b750               
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.118***          -0.030***     -0.052***  
##                             (0.028)            (0.011)       (0.017)   
##                                                                        
## Constant                   38.770***           3.114***     34.870***  
##                             (0.864)            (0.551)       (2.507)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.024                                     
## Adjusted R2                  0.023                                     
## Log Likelihood                                -2,096.987    -2,096.434 
## sigma2                                          19.641        19.566   
## Akaike Inf. Crit.                             4,201.973     4,200.867  
## Residual Std. Error    12.045 (df = 686)                               
## F Statistic         17.076*** (df = 1; 686)                            
## Wald Test (df = 1)                           5,945.135***  6,017.066***
## LR Test (df = 1)                             1,180.832***  1,181.938***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

4.1.2.3 Canopy (trees)

Measuring high canopy (i.e. trees only) ratio within CT/buffer in 2011 (in %)

4.1.2.3.1 Census tract level
f <- pct_esp_vert_high_2011ct ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011ct, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -18.326  -6.268  -1.733   4.591  49.674 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       21.65430    0.66887  32.375  < 2e-16 ***
## vis_minority_2011 -0.13440    0.02205  -6.095 1.83e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.319 on 686 degrees of freedom
## Multiple R-squared:  0.05137,    Adjusted R-squared:  0.04999 
## F-statistic: 37.15 on 1 and 686 DF,  p-value: 1.826e-09
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 20.232, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.4636013872    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 400.45, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 368.48, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 41.834, df = 1, p-value = 9.938e-11
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 9.8689, df = 1, p-value = 0.001681
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 410.32, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                                 pct_esp_vert_high_2011ct             
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## vis_minority_2011          -0.134***          -0.099***    -0.185*** 
##                             (0.022)            (0.018)      (0.026)  
##                                                                      
## Constant                   21.654***           8.519***    23.151*** 
##                             (0.669)            (0.916)      (1.100)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.051                                   
## Adjusted R2                  0.050                                   
## Log Likelihood                                -2,379.295   -2,370.442
## sigma2                                          53.063       51.432  
## Akaike Inf. Crit.                             4,766.589    4,748.885 
## Residual Std. Error    9.319 (df = 686)                              
## F Statistic         37.149*** (df = 1; 686)                          
## Wald Test (df = 1)                            403.008***   418.821***
## LR Test (df = 1)                              263.237***   280.941***
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
4.1.2.3.2 Buffer 250m
f <- pct_esp_vert_high_2011b250 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b250, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.868  -5.219  -1.577   3.865  30.099 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       19.64095    0.54328  36.152  < 2e-16 ***
## vis_minority_2011 -0.09512    0.01791  -5.311 1.48e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.57 on 686 degrees of freedom
## Multiple R-squared:  0.03949,    Adjusted R-squared:  0.03809 
## F-statistic:  28.2 on 1 and 686 DF,  p-value: 1.478e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 26.069, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5980160072    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 666.32, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 636.11, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 34.646, df = 1, p-value = 3.954e-09
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 4.4392, df = 1, p-value = 0.03512
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 670.76, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                 pct_esp_vert_high_2011b250             
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.095***          -0.057***     -0.111***  
##                             (0.018)            (0.012)       (0.018)   
##                                                                        
## Constant                   19.641***           4.622***     20.207***  
##                             (0.543)            (0.593)       (1.116)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.039                                     
## Adjusted R2                  0.038                                     
## Log Likelihood                                -2,121.080    -2,114.967 
## sigma2                                          23.271        22.822   
## Akaike Inf. Crit.                             4,250.161     4,237.935  
## Residual Std. Error    7.570 (df = 686)                                
## F Statistic         28.203*** (df = 1; 686)                            
## Wald Test (df = 1)                           1,262.753***  1,223.662***
## LR Test (df = 1)                              493.526***    505.752*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.2.3.3 Buffer 500m
f <- pct_esp_vert_high_2011b500 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b500, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.831  -4.955  -1.786   3.823  30.706 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       19.14657    0.51243  37.364  < 2e-16 ***
## vis_minority_2011 -0.07172    0.01689  -4.245 2.48e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.14 on 686 degrees of freedom
## Multiple R-squared:  0.0256, Adjusted R-squared:  0.02418 
## F-statistic: 18.02 on 1 and 686 DF,  p-value: 2.483e-05
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 29.01, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6657435554    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 825.79, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 804.28, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 23.71, df = 1, p-value = 1.12e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 2.1982, df = 1, p-value = 0.1382
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 827.99, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                 pct_esp_vert_high_2011b500             
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.072***          -0.037***     -0.071***  
##                             (0.017)            (0.010)       (0.015)   
##                                                                        
## Constant                   19.147***           3.096***     19.273***  
##                             (0.512)            (0.461)       (1.275)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.026                                     
## Adjusted R2                  0.024                                     
## Log Likelihood                                -1,995.712    -1,992.790 
## sigma2                                          15.451        15.320   
## Akaike Inf. Crit.                             3,999.424     3,993.579  
## Residual Std. Error    7.140 (df = 686)                                
## F Statistic         18.023*** (df = 1; 686)                            
## Wald Test (df = 1)                           2,450.649***  2,346.072***
## LR Test (df = 1)                              663.802***    669.647*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.2.3.4 Buffer 750m
f <- pct_esp_vert_high_2011b750 ~ vis_minority_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b750, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.139  -4.491  -1.597   3.722  28.116 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       18.81117    0.48825   38.53  < 2e-16 ***
## vis_minority_2011 -0.05747    0.01610   -3.57 0.000381 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.803 on 686 degrees of freedom
## Multiple R-squared:  0.01824,    Adjusted R-squared:  0.01681 
## F-statistic: 12.75 on 1 and 686 DF,  p-value: 0.0003812
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 30.981, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7111326230    -0.0023408477     0.0005303562
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 942.23, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 926.58, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 16.723, df = 1, p-value = 4.326e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 1.0741, df = 1, p-value = 0.3
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 943.3, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                     ---------------------------------------------------
##                                 pct_esp_vert_high_2011b750             
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## vis_minority_2011          -0.057***          -0.026***     -0.047***  
##                             (0.016)            (0.008)       (0.013)   
##                                                                        
## Constant                   18.811***           2.238***     18.498***  
##                             (0.488)            (0.375)       (1.426)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.018                                     
## Adjusted R2                  0.017                                     
## Log Likelihood                                -1,893.210    -1,892.065 
## sigma2                                          11.127        11.093   
## Akaike Inf. Crit.                             3,794.420     3,792.131  
## Residual Std. Error    6.803 (df = 686)                                
## F Statistic         12.748*** (df = 1; 686)                            
## Wald Test (df = 1)                           3,934.923***  3,787.643***
## LR Test (df = 1)                              802.301***    804.591*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

4.1.3 UC vs gentrified CT

Gentrified CT between 2011 and 2016

4.1.3.1 Bike lane length

Bike lane ratio to streets (in %)

4.1.3.1.1 Census tract level
f <- Bike_lane.by.street.2011ct ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011ct, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane.by.street.2011ct, na.rm = TRUE),
    sd = sd(Bike_lane.by.street.2011ct, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)
## gentrified_2016_2011   1      5    4.85   0.055  0.815
## Residuals            686  60733   88.53
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -8.758 -8.575 -1.813  5.132 55.346 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                8.7583     0.4295  20.393   <2e-16 ***
## gentrified_2016_2011TRUE  -0.1828     0.7811  -0.234    0.815    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.409 on 686 degrees of freedom
## Multiple R-squared:  7.988e-05,  Adjusted R-squared:  -0.001378 
## F-statistic: 0.0548 on 1 and 686 DF,  p-value: 0.815
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 11.206, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.2563534625    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 122.44, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 122.35, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.34145, df = 1, p-value = 0.559
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 0.2437, df = 1, p-value = 0.6215
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 122.69, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==================================================================
##                                   Dependent variable:             
##                      ---------------------------------------------
##                               Bike_lane.by.street.2011ct          
##                              OLS            spatial      spatial  
##                                          autoregressive   error   
##                              (1)              (2)          (3)    
## ------------------------------------------------------------------
## gentrified_2016_2011       -0.183            -0.190       -0.340  
##                            (0.781)          (0.709)      (0.773)  
##                                                                   
## Constant                  8.758***          4.521***     8.862*** 
##                            (0.429)          (0.557)      (0.682)  
##                                                                   
## ------------------------------------------------------------------
## Observations                 688              688          688    
## R2                         0.0001                                 
## Adjusted R2                -0.001                                 
## Log Likelihood                             -2,469.583   -2,469.522
## sigma2                                       73.023       73.003  
## Akaike Inf. Crit.                          4,947.166    4,947.045 
## Residual Std. Error   9.409 (df = 686)                            
## F Statistic          0.055 (df = 1; 686)                          
## Wald Test (df = 1)                         117.326***   117.591***
## LR Test (df = 1)                           95.848***    95.969*** 
## ==================================================================
## Note:                                  *p<0.1; **p<0.05; ***p<0.01
4.1.3.1.2 Buffers 250m
f <- Bike_lane.by.street.2011b250 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b250, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane.by.street.2011b250, na.rm = TRUE),
    sd = sd(Bike_lane.by.street.2011b250, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)
## gentrified_2016_2011   1      2    1.62   0.036   0.85
## Residuals            686  30955   45.12
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.7878 -4.9601 -0.6952  4.0764 23.9638 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                8.6822     0.3066  28.317   <2e-16 ***
## gentrified_2016_2011TRUE   0.1056     0.5576   0.189     0.85    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.717 on 686 degrees of freedom
## Multiple R-squared:  5.229e-05,  Adjusted R-squared:  -0.001405 
## F-statistic: 0.03588 on 1 and 686 DF,  p-value: 0.8498
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 23.149, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5315096896    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 526.35, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 526.65, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.78099, df = 1, p-value = 0.3768
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 1.0731, df = 1, p-value = 0.3002
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 527.43, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==================================================================
##                                   Dependent variable:             
##                      ---------------------------------------------
##                              Bike_lane.by.street.2011b250         
##                              OLS            spatial      spatial  
##                                          autoregressive   error   
##                              (1)              (2)          (3)    
## ------------------------------------------------------------------
## gentrified_2016_2011        0.106            -0.174       -0.320  
##                            (0.558)          (0.380)      (0.416)  
##                                                                   
## Constant                  8.682***          1.966***     9.376*** 
##                            (0.307)          (0.318)      (0.857)  
##                                                                   
## ------------------------------------------------------------------
## Observations                 688              688          688    
## R2                         0.0001                                 
## Adjusted R2                -0.001                                 
## Log Likelihood                             -2,080.446   -2,080.257
## sigma2                                       20.986       20.973  
## Akaike Inf. Crit.                          4,168.893    4,168.514 
## Residual Std. Error   6.717 (df = 686)                            
## F Statistic          0.036 (df = 1; 686)                          
## Wald Test (df = 1)                         959.744***   960.343***
## LR Test (df = 1)                           410.438***   410.817***
## ==================================================================
## Note:                                  *p<0.1; **p<0.05; ***p<0.01
4.1.3.1.3 Buffers 500m
f <- Bike_lane.by.street.2011b500 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b500, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane.by.street.2011b500, na.rm = TRUE),
    sd = sd(Bike_lane.by.street.2011b500, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)
## gentrified_2016_2011   1     24   23.81   0.727  0.394
## Residuals            686  22481   32.77
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.060 -4.144 -0.565  3.132 19.603 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                8.6548     0.2613  33.123   <2e-16 ***
## gentrified_2016_2011TRUE   0.4051     0.4752   0.852    0.394    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.725 on 686 degrees of freedom
## Multiple R-squared:  0.001058,   Adjusted R-squared:  -0.0003982 
## F-statistic: 0.7266 on 1 and 686 DF,  p-value: 0.3943
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 28.018, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6436934583    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 771.99, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 773.29, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.13466, df = 1, p-value = 0.7136
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 1.4313, df = 1, p-value = 0.2315
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 773.43, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ====================================================================
##                                    Dependent variable:              
##                      -----------------------------------------------
##                               Bike_lane.by.street.2011b500          
##                              OLS            spatial       spatial   
##                                          autoregressive    error    
##                              (1)              (2)           (3)     
## --------------------------------------------------------------------
## gentrified_2016_2011        0.405            0.064         0.067    
##                            (0.475)          (0.268)       (0.292)   
##                                                                     
## Constant                  8.655***          1.214***      9.716***  
##                            (0.261)          (0.232)       (0.976)   
##                                                                     
## --------------------------------------------------------------------
## Observations                 688              688           688     
## R2                          0.001                                   
## Adjusted R2                -0.0004                                  
## Log Likelihood                             -1,858.533    -1,858.535 
## sigma2                                       10.400        10.399   
## Akaike Inf. Crit.                          3,725.067     3,725.071  
## Residual Std. Error   5.725 (df = 686)                              
## F Statistic          0.727 (df = 1; 686)                            
## Wald Test (df = 1)                        2,244.147***  2,247.826***
## LR Test (df = 1)                           634.195***    634.191*** 
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
4.1.3.1.4 Buffers 750m
f <- Bike_lane.by.street.2011b750 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane.by.street.2011b750, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane.by.street.2011b750, na.rm = TRUE),
    sd = sd(Bike_lane.by.street.2011b750, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)
## gentrified_2016_2011   1     45   44.85   1.701  0.193
## Residuals            686  18086   26.36
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.2152 -3.7776 -0.7069  2.6088 19.1333 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                8.6593     0.2344  36.948   <2e-16 ***
## gentrified_2016_2011TRUE   0.5559     0.4262   1.304    0.193    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.135 on 686 degrees of freedom
## Multiple R-squared:  0.002474,   Adjusted R-squared:  0.001019 
## F-statistic: 1.701 on 1 and 686 DF,  p-value: 0.1926
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 30.962, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7115195894    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 943.26, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 945.77, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.037286, df = 1, p-value = 0.8469
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 2.5467, df = 1, p-value = 0.1105
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 945.8, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ====================================================================
##                                    Dependent variable:              
##                      -----------------------------------------------
##                               Bike_lane.by.street.2011b750          
##                              OLS            spatial       spatial   
##                                          autoregressive    error    
##                              (1)              (2)           (3)     
## --------------------------------------------------------------------
## gentrified_2016_2011        0.556            0.148         0.150    
##                            (0.426)          (0.207)       (0.224)   
##                                                                     
## Constant                  8.659***          0.855***     10.055***  
##                            (0.234)          (0.183)       (1.073)   
##                                                                     
## --------------------------------------------------------------------
## Observations                 688              688           688     
## R2                          0.002                                   
## Adjusted R2                 0.001                                   
## Log Likelihood                             -1,692.657    -1,692.690 
## sigma2                                       6.195         6.193    
## Akaike Inf. Crit.                          3,393.313     3,393.380  
## Residual Std. Error   5.135 (df = 686)                              
## F Statistic          1.701 (df = 1; 686)                            
## Wald Test (df = 1)                        3,985.018***  4,005.754***
## LR Test (df = 1)                           816.292***    816.225*** 
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01

4.1.3.2 Canopy

Measuring canopy (i.e. greenness ~ grass & trees) ratio within CT/buffer in 2011 (in %)

4.1.3.2.1 Census tract level
f <- pct_esp_vert_2011ct ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011ct, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_2011ct, na.rm = TRUE),
    sd = sd(pct_esp_vert_2011ct, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)    
## gentrified_2016_2011   1  22875   22875   101.7 <2e-16 ***
## Residuals            686 154327     225                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -36.894 -10.243  -0.814   8.634  50.896 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               41.0543     0.6846   59.97   <2e-16 ***
## gentrified_2016_2011TRUE -12.5551     1.2451  -10.08   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15 on 686 degrees of freedom
## Multiple R-squared:  0.1291, Adjusted R-squared:  0.1278 
## F-statistic: 101.7 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 25.235, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5795700127    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 625.85, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 723.74, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 1.1096, df = 1, p-value = 0.2922
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 98.999, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 724.85, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                      --------------------------------------------------
##                                     pct_esp_vert_2011ct                
##                                OLS               spatial      spatial  
##                                               autoregressive   error   
##                                (1)                 (2)          (3)    
## -----------------------------------------------------------------------
## gentrified_2016_2011        -12.555***          -5.010***    -3.836*** 
##                              (1.245)             (0.808)      (0.873)  
##                                                                        
## Constant                    41.054***           10.141***    38.544*** 
##                              (0.685)             (1.122)      (1.796)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                   688                 688          688    
## R2                            0.129                                    
## Adjusted R2                   0.128                                    
## Log Likelihood                                  -2,580.444   -2,589.339
## sigma2                                            91.071       92.121  
## Akaike Inf. Crit.                               5,168.889    5,186.679 
## Residual Std. Error     14.999 (df = 686)                              
## F Statistic          101.681*** (df = 1; 686)                          
## Wald Test (df = 1)                              849.594***   960.428***
## LR Test (df = 1)                                515.742***   497.952***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
4.1.3.2.2 Buffer 250m
f <- pct_esp_vert_2011b250 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b250, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_2011b250, na.rm = TRUE),
    sd = sd(pct_esp_vert_2011b250, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)    
## gentrified_2016_2011   1  14758   14758   94.24 <2e-16 ***
## Residuals            686 107422     157                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.278  -8.147  -1.213   7.608  40.172 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               38.6279     0.5712  67.630   <2e-16 ***
## gentrified_2016_2011TRUE -10.0845     1.0388  -9.708   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.51 on 686 degrees of freedom
## Multiple R-squared:  0.1208, Adjusted R-squared:  0.1195 
## F-statistic: 94.24 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 29.515, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6781843890    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 856.94, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 980.26, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 1.3205, df = 1, p-value = 0.2505
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 124.64, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 981.58, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                      Dependent variable:                
##                      ---------------------------------------------------
##                                     pct_esp_vert_2011b250               
##                                OLS              spatial       spatial   
##                                              autoregressive    error    
##                                (1)                (2)           (3)     
## ------------------------------------------------------------------------
## gentrified_2016_2011       -10.084***          -2.423***      -1.403**  
##                              (1.039)            (0.526)       (0.566)   
##                                                                         
## Constant                    38.628***           5.505***     35.468***  
##                              (0.571)            (0.742)       (2.010)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                   688                688           688     
## R2                            0.121                                     
## Adjusted R2                   0.120                                     
## Log Likelihood                                 -2,310.879    -2,317.906 
## sigma2                                           39.039        39.285   
## Akaike Inf. Crit.                              4,629.758     4,643.812  
## Residual Std. Error     12.514 (df = 686)                               
## F Statistic          94.244*** (df = 1; 686)                            
## Wald Test (df = 1)                            2,124.690***  2,473.599***
## LR Test (df = 1)                               805.605***    791.551*** 
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
4.1.3.2.3 Buffer 500m
f <- pct_esp_vert_2011b500 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b500, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_2011b500, na.rm = TRUE),
    sd = sd(pct_esp_vert_2011b500, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)    
## gentrified_2016_2011   1  12593   12593    89.4 <2e-16 ***
## Residuals            686  96625     141                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.186  -7.826  -1.241   7.487  38.114 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               38.4760     0.5417  71.028   <2e-16 ***
## gentrified_2016_2011TRUE  -9.3153     0.9852  -9.455   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.87 on 686 degrees of freedom
## Multiple R-squared:  0.1153, Adjusted R-squared:  0.114 
## F-statistic:  89.4 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 31.173, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7163981718    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 956.23, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1084.9, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 1.2145, df = 1, p-value = 0.2704
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 129.92, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1086.2, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                      Dependent variable:                
##                      ---------------------------------------------------
##                                     pct_esp_vert_2011b500               
##                                OLS              spatial       spatial   
##                                              autoregressive    error    
##                                (1)                (2)           (3)     
## ------------------------------------------------------------------------
## gentrified_2016_2011        -9.315***          -1.669***      -0.799*   
##                              (0.985)            (0.434)       (0.468)   
##                                                                         
## Constant                    38.476***           3.964***     34.701***  
##                              (0.542)            (0.597)       (2.256)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                   688                688           688     
## R2                            0.115                                     
## Adjusted R2                   0.114                                     
## Log Likelihood                                 -2,193.040    -2,198.576 
## sigma2                                           26.833        26.928   
## Akaike Inf. Crit.                              4,394.080     4,405.153  
## Residual Std. Error     11.868 (df = 686)                               
## F Statistic          89.402*** (df = 1; 686)                            
## Wald Test (df = 1)                            3,471.901***  4,059.239***
## LR Test (df = 1)                               968.405***    957.333*** 
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
4.1.3.2.4 Buffer 750m
f <- pct_esp_vert_2011b750 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_2011b750, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_2011b750, na.rm = TRUE),
    sd = sd(pct_esp_vert_2011b750, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)    
## gentrified_2016_2011   1  10896   10896   82.04 <2e-16 ***
## Residuals            686  91103     133                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.094  -7.876  -1.059   7.284  37.706 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               38.3636     0.5260  72.935   <2e-16 ***
## gentrified_2016_2011TRUE  -8.6650     0.9566  -9.058   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.52 on 686 degrees of freedom
## Multiple R-squared:  0.1068, Adjusted R-squared:  0.1055 
## F-statistic: 82.04 on 1 and 686 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 32.594, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7491283829    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1045.6, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1175, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 1.2533, df = 1, p-value = 0.2629
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 130.64, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1176.2, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                      Dependent variable:                
##                      ---------------------------------------------------
##                                     pct_esp_vert_2011b750               
##                                OLS              spatial       spatial   
##                                              autoregressive    error    
##                                (1)                (2)           (3)     
## ------------------------------------------------------------------------
## gentrified_2016_2011        -8.665***          -1.088***       -0.388   
##                              (0.957)            (0.371)       (0.400)   
##                                                                         
## Constant                    38.364***           2.890***     33.574***  
##                              (0.526)            (0.487)       (2.501)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                   688                688           688     
## R2                            0.107                                     
## Adjusted R2                   0.106                                     
## Log Likelihood                                 -2,096.838    -2,100.429 
## sigma2                                           19.768        19.780   
## Akaike Inf. Crit.                              4,201.676     4,208.859  
## Residual Std. Error     11.524 (df = 686)                               
## F Statistic          82.043*** (df = 1; 686)                            
## Wald Test (df = 1)                            5,278.361***  6,097.477***
## LR Test (df = 1)                              1,120.323***  1,113.140***
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01

4.1.3.3 Canopy (trees)

Measuring high canopy (i.e. trees only) ratio within CT/buffer in 2011 (in %)

4.1.3.3.1 Census tract level
f <- pct_esp_vert_high_2011ct ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011ct, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_high_2011ct, na.rm = TRUE),
    sd = sd(pct_esp_vert_high_2011ct, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1   1754    1754   19.71 1.05e-05 ***
## Residuals            686  61052      89                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -17.351  -6.220  -1.698   4.219  49.349 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               19.2515     0.4306   44.71  < 2e-16 ***
## gentrified_2016_2011TRUE  -3.4770     0.7831   -4.44 1.05e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.434 on 686 degrees of freedom
## Multiple R-squared:  0.02793,    Adjusted R-squared:  0.02652 
## F-statistic: 19.71 on 1 and 686 DF,  p-value: 1.049e-05
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 18.905, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.4337406070    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 350.52, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 359.28, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.0023037, df = 1, p-value = 0.9617
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 8.7561, df = 1, p-value = 0.003086
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 359.28, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ======================================================================
##                                     Dependent variable:               
##                      -------------------------------------------------
##                                  pct_esp_vert_high_2011ct             
##                                OLS              spatial      spatial  
##                                              autoregressive   error   
##                                (1)                (2)          (3)    
## ----------------------------------------------------------------------
## gentrified_2016_2011        -3.477***          -2.114***    -2.060*** 
##                              (0.783)            (0.617)      (0.674)  
##                                                                       
## Constant                    19.251***           6.585***    18.999*** 
##                              (0.431)            (0.726)      (0.910)  
##                                                                       
## ----------------------------------------------------------------------
## Observations                   688                688          688    
## R2                            0.028                                   
## Adjusted R2                   0.027                                   
## Log Likelihood                                 -2,389.431   -2,390.646
## sigma2                                           54.608       54.672  
## Akaike Inf. Crit.                              4,786.863    4,789.292 
## Residual Std. Error     9.434 (df = 686)                              
## F Statistic          19.712*** (df = 1; 686)                          
## Wald Test (df = 1)                             396.467***   402.598***
## LR Test (df = 1)                               259.756***   257.327***
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01
4.1.3.3.2 Buffer 250m
f <- pct_esp_vert_high_2011b250 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b250, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_high_2011b250, na.rm = TRUE),
    sd = sd(pct_esp_vert_high_2011b250, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1    769   769.1   13.14 0.000311 ***
## Residuals            686  40155    58.5                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.682  -5.228  -1.545   3.697  31.538 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               17.8925     0.3492  51.237  < 2e-16 ***
## gentrified_2016_2011TRUE  -2.3022     0.6351  -3.625 0.000311 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.651 on 686 degrees of freedom
## Multiple R-squared:  0.01879,    Adjusted R-squared:  0.01736 
## F-statistic: 13.14 on 1 and 686 DF,  p-value: 0.0003105
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 25.018, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5745722794    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 615.1, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 627.01, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.099544, df = 1, p-value = 0.7524
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 12.012, df = 1, p-value = 0.0005287
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 627.11, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                      Dependent variable:                
##                      ---------------------------------------------------
##                                  pct_esp_vert_high_2011b250             
##                                OLS              spatial       spatial   
##                                              autoregressive    error    
##                                (1)                (2)           (3)     
## ------------------------------------------------------------------------
## gentrified_2016_2011        -2.302***           -0.982**       -0.713   
##                              (0.635)            (0.407)       (0.444)   
##                                                                         
## Constant                    17.893***           3.418***     17.529***  
##                              (0.349)            (0.469)       (1.061)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                   688                688           688     
## R2                            0.019                                     
## Adjusted R2                   0.017                                     
## Log Likelihood                                 -2,130.271    -2,131.889 
## sigma2                                           23.861        23.925   
## Akaike Inf. Crit.                              4,268.542     4,271.777  
## Residual Std. Error     7.651 (df = 686)                                
## F Statistic          13.139*** (df = 1; 686)                            
## Wald Test (df = 1)                            1,242.858***  1,260.359***
## LR Test (df = 1)                               489.811***    486.576*** 
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
4.1.3.3.3 Buffer 500m
f <- pct_esp_vert_high_2011b500 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b500, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_high_2011b500, na.rm = TRUE),
    sd = sd(pct_esp_vert_high_2011b500, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1    611   610.9   11.88 0.000602 ***
## Residuals            686  35277    51.4                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.834  -4.709  -1.358   3.914  31.046 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               17.9237     0.3273  54.760  < 2e-16 ***
## gentrified_2016_2011TRUE  -2.0517     0.5953  -3.447 0.000602 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.171 on 686 degrees of freedom
## Multiple R-squared:  0.01702,    Adjusted R-squared:  0.01559 
## F-statistic: 11.88 on 1 and 686 DF,  p-value: 0.0006024
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 28.201, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6479224174    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 782.17, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 794.16, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.0077491, df = 1, p-value = 0.9299
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 11.997, df = 1, p-value = 0.0005328
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 794.17, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ========================================================================
##                                      Dependent variable:                
##                      ---------------------------------------------------
##                                  pct_esp_vert_high_2011b500             
##                                OLS              spatial       spatial   
##                                              autoregressive    error    
##                                (1)                (2)           (3)     
## ------------------------------------------------------------------------
## gentrified_2016_2011        -2.052***           -0.733**       -0.515   
##                              (0.595)            (0.330)       (0.358)   
##                                                                         
## Constant                    17.924***           2.356***     17.576***  
##                              (0.327)            (0.368)       (1.262)   
##                                                                         
## ------------------------------------------------------------------------
## Observations                   688                688           688     
## R2                            0.017                                     
## Adjusted R2                   0.016                                     
## Log Likelihood                                 -2,001.023    -2,002.461 
## sigma2                                           15.682        15.715   
## Akaike Inf. Crit.                              4,010.046     4,012.921  
## Residual Std. Error     7.171 (df = 686)                                
## F Statistic          11.879*** (df = 1; 686)                            
## Wald Test (df = 1)                            2,404.771***  2,443.351***
## LR Test (df = 1)                               659.211***    656.336*** 
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
4.1.3.3.4 Buffer 750m
f <- pct_esp_vert_high_2011b750 ~ gentrified_2016_2011

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_high_2011b750, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_high_2011b750, na.rm = TRUE),
    sd = sd(pct_esp_vert_high_2011b750, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(f, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value  Pr(>F)   
## gentrified_2016_2011   1    453   452.6   9.737 0.00188 **
## Residuals            686  31885    46.5                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -13.348  -4.724  -1.360   3.591  28.352 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               17.8681     0.3112   57.42  < 2e-16 ***
## gentrified_2016_2011TRUE  -1.7660     0.5659   -3.12  0.00188 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.818 on 686 degrees of freedom
## Multiple R-squared:  0.014,  Adjusted R-squared:  0.01256 
## F-statistic: 9.737 on 1 and 686 DF,  p-value: 0.001881
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 30.329, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6969550748    -0.0018276221     0.0005308315
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 905.03, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 916.99, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.030106, df = 1, p-value = 0.8623
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 11.982, df = 1, p-value = 0.0005371
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 917.02, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                     Dependent variable:                
##                      --------------------------------------------------
##                                  pct_esp_vert_high_2011b750            
##                               OLS              spatial       spatial   
##                                             autoregressive    error    
##                               (1)                (2)           (3)     
## -----------------------------------------------------------------------
## gentrified_2016_2011       -1.766***           -0.495*        -0.296   
##                             (0.566)            (0.279)       (0.302)   
##                                                                        
## Constant                   17.868***           1.722***     17.348***  
##                             (0.311)            (0.300)       (1.432)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                  688                688           688     
## R2                           0.014                                     
## Adjusted R2                  0.013                                     
## Log Likelihood                                -1,896.865    -1,897.957 
## sigma2                                          11.241        11.258   
## Akaike Inf. Crit.                             3,801.729     3,803.915  
## Residual Std. Error     6.818 (df = 686)                               
## F Statistic          9.737*** (df = 1; 686)                            
## Wald Test (df = 1)                           3,873.748***  3,940.012***
## LR Test (df = 1)                              797.963***    795.777*** 
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01

5 Association between SES and Urban Interventions at baseline (2011)

Looking at objective #1 | do urban interventions tend to be located in low SES neighborhoods?. We look at \[Urban Intervention_{2011 \to 2016} = f(SES_{2011})\] as well as \[Urban Intervention_{2011 \to 2016} = f(Gentrification_{2011 \to 2016})\]

Here \(Urban Intervention\) means the changes in the urban environment features, such as variation of bike lane length, greenness coverage, etc.

5.1 INTERACT study area

# keep only interact CT
bei_df_aoi <- filter(bei_df, interact_aoi)

5.1.1 UI vs Pampalon | material

5.1.1.1 Bike lane length change

Bike lane ratio to streets (in %)

5.1.1.1.1 Census tract level
f <- Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016ct, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm.0 <- lm(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm.0)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.442  -3.695  -3.621   0.992  38.452 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.6795     0.2761  13.328   <2e-16 ***
## wSCOREMAT.2011  -1.2310     6.7303  -0.183    0.855    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.194 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  4.862e-05,  Adjusted R-squared:  -0.001405 
## F-statistic: 0.03345 on 1 and 688 DF,  p-value: 0.8549
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.611  -4.270  -3.060   1.535  37.473 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 4.64360    0.37631  12.340  < 2e-16 ***
## wSCOREMAT.2011             -4.54494    6.74316  -0.674 0.500534    
## Bike_lane.by.street.2011ct -0.10698    0.02896  -3.694 0.000238 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.136 on 685 degrees of freedom
## Multiple R-squared:  0.01961,    Adjusted R-squared:  0.01675 
## F-statistic: 6.852 on 2 and 685 DF,  p-value: 0.001131
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 16.342, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3735012941    -0.0026011376     0.0005296578
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 259.76, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 267.97, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 1.499, df = 1, p-value = 0.2208
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 9.71, df = 1, p-value = 0.001833
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 269.47, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ===========================================================================
##                                          Dependent variable:               
##                            ------------------------------------------------
##                                  Bike_lane_diff.by.street.2011.2016ct      
##                                     OLS              spatial      spatial  
##                                                   autoregressive   error   
##                                     (1)                (2)          (3)    
## ---------------------------------------------------------------------------
## wSCOREMAT.2011                     -4.545             -2.672       -3.332  
##                                   (6.743)            (5.566)      (7.632)  
##                                                                            
## Bike_lane.by.street.2011ct       -0.107***           -0.055**     -0.048*  
##                                   (0.029)            (0.024)      (0.026)  
##                                                                            
## Constant                          4.644***           1.917***     4.279*** 
##                                   (0.376)            (0.347)      (0.657)  
##                                                                            
## ---------------------------------------------------------------------------
## Observations                        688                688          688    
## R2                                 0.020                                   
## Adjusted R2                        0.017                                   
## Log Likelihood                                      -2,227.328   -2,228.225
## sigma2                                                34.700       34.743  
## Akaike Inf. Crit.                                   4,464.656    4,466.449 
## Residual Std. Error           7.136 (df = 685)                             
## F Statistic                6.852*** (df = 2; 685)                          
## Wald Test (df = 1)                                  284.515***   289.723***
## LR Test (df = 1)                                    198.910***   197.117***
## ===========================================================================
## Note:                                           *p<0.1; **p<0.05; ***p<0.01
5.1.1.1.2 Buffers 250m
f <- Bike_lane_diff.by.street.2011.2016b250 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b250, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016b250 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b250 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.425  -3.455  -2.437   1.626  27.938 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.4854     0.2095  16.637   <2e-16 ***
## wSCOREMAT.2011  -5.3511     5.1073  -1.048    0.295    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.459 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.001593,   Adjusted R-squared:  0.0001418 
## F-statistic: 1.098 on 1 and 688 DF,  p-value: 0.2951
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.113  -3.618  -1.900   1.831  26.237 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                    5.23428    0.34085  15.357  < 2e-16 ***
## wSCOREMAT.2011               -12.39619    5.08948  -2.436   0.0151 *  
## Bike_lane.by.street.2011b250  -0.19423    0.03061  -6.346 4.02e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.31 on 685 degrees of freedom
## Multiple R-squared:  0.0573, Adjusted R-squared:  0.05455 
## F-statistic: 20.82 on 2 and 685 DF,  p-value: 1.67e-09
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 27.752, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##      0.635433896     -0.003000503      0.000529222
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 751.83, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 755.38, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 4.7279, df = 1, p-value = 0.02968
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 8.2778, df = 1, p-value = 0.004013
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 760.11, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ================================================================================
##                                              Dependent variable:                
##                              ---------------------------------------------------
##                                    Bike_lane_diff.by.street.2011.2016b250       
##                                        OLS              spatial       spatial   
##                                                      autoregressive    error    
##                                        (1)                (2)           (3)     
## --------------------------------------------------------------------------------
## wSCOREMAT.2011                      -12.396**           -6.104**      -8.888**  
##                                      (5.089)            (2.897)       (4.206)   
##                                                                                 
## Bike_lane.by.street.2011b250        -0.194***          -0.065***     -0.078***  
##                                      (0.031)            (0.018)       (0.025)   
##                                                                                 
## Constant                            5.234***            1.113***      4.674***  
##                                      (0.341)            (0.218)       (0.934)   
##                                                                                 
## --------------------------------------------------------------------------------
## Observations                           688                688           688     
## R2                                    0.057                                     
## Adjusted R2                           0.055                                     
## Log Likelihood                                         -1,809.458    -1,811.112 
## sigma2                                                   9.069         9.070    
## Akaike Inf. Crit.                                      3,628.916     3,632.224  
## Residual Std. Error             5.310 (df = 685)                                
## F Statistic                  20.818*** (df = 2; 685)                            
## Wald Test (df = 1)                                    2,138.032***  2,211.065***
## LR Test (df = 1)                                       628.015***    624.707*** 
## ================================================================================
## Note:                                                *p<0.1; **p<0.05; ***p<0.01
5.1.1.1.3 Buffers 500m
f <- Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b500, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.367 -3.310 -1.827  2.005 18.540 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.4779     0.1803   19.29   <2e-16 ***
## wSCOREMAT.2011  -6.4606     4.3960   -1.47    0.142    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.699 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.00313,    Adjusted R-squared:  0.001681 
## F-statistic:  2.16 on 1 and 688 DF,  p-value: 0.1421
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -8.425 -3.242 -1.525  2.097 18.606 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                    5.15103    0.32950  15.633  < 2e-16 ***
## wSCOREMAT.2011               -12.64620    4.40584  -2.870  0.00423 ** 
## Bike_lane.by.street.2011b500  -0.18472    0.03107  -5.945  4.4e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.582 on 685 degrees of freedom
## Multiple R-squared:  0.05248,    Adjusted R-squared:  0.04972 
## F-statistic: 18.97 on 2 and 685 DF,  p-value: 9.567e-09
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 33.544, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7683768353    -0.0031664873     0.0005290487
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1099.3, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1096.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 8.7504, df = 1, p-value = 0.003095
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 5.9047, df = 1, p-value = 0.0151
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1105.2, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ================================================================================
##                                              Dependent variable:                
##                              ---------------------------------------------------
##                                    Bike_lane_diff.by.street.2011.2016b500       
##                                        OLS              spatial       spatial   
##                                                      autoregressive    error    
##                                        (1)                (2)           (3)     
## --------------------------------------------------------------------------------
## wSCOREMAT.2011                     -12.646***          -5.264***     -8.544***  
##                                      (4.406)            (1.874)       (2.709)   
##                                                                                 
## Bike_lane.by.street.2011b500        -0.185***          -0.043***     -0.070***  
##                                      (0.031)            (0.013)       (0.023)   
##                                                                                 
## Constant                            5.151***            0.654***      4.297***  
##                                      (0.329)            (0.153)       (1.106)   
##                                                                                 
## --------------------------------------------------------------------------------
## Observations                           688                688           688     
## R2                                    0.052                                     
## Adjusted R2                           0.050                                     
## Log Likelihood                                         -1,525.169    -1,524.317 
## sigma2                                                   3.736         3.708    
## Akaike Inf. Crit.                                      3,060.339     3,058.634  
## Residual Std. Error             4.582 (df = 685)                                
## F Statistic                  18.972*** (df = 2; 685)                            
## Wald Test (df = 1)                                    5,791.536***  6,051.759***
## LR Test (df = 1)                                       993.661***    995.366*** 
## ================================================================================
## Note:                                                *p<0.1; **p<0.05; ***p<0.01
# Build adjacency matrix to feed spaMM models
ct_nb <- poly2nb(CT16, row.names = "GeoUID")
mtx_nb <- nb2mat(ct_nb, style = "B", zero.policy = TRUE)

ct_mtx_lut <- CT16 %>%
  as.data.frame() %>%
  transmute(CT_UID = GeoUID,
            CT_Code = row_number())

# spaMM approach: mixed-effect models
test.spm <- fitme(Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b500 + adjacency(1|CT_Code),
                  data = inner_join(bei_df_aoi, ct_mtx_lut, by="CT_UID"), adjMatrix = mtx_nb)
summary(test.spm)

#test.spm.1 <- HLCor(Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b500 + adjacency(1|CT_Code),
#                  data = inner_join(bei_df_aoi, ct_mtx_lut, by="CT_UID"), adjMatrix = mtx_nb)
#summary(test.spm.1)

test.lmm <- inla(Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b500,
                 data = inner_join(bei_df_aoi, ct_mtx_lut, by="CT_UID"),
                 control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.lmm)

test.lmm.iid <- inla(Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b500 + 
                      f(CT_Code, model='iid'),
                  data = inner_join(bei_df_aoi, ct_mtx_lut, by="CT_UID"),
                 control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.lmm.iid)

test.lmm.bym <- inla(Bike_lane_diff.by.street.2011.2016b500 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b500 + 
                      f(CT_Code, model='bym', graph=mtx_nb),
                  data = inner_join(bei_df_aoi, ct_mtx_lut, by="CT_UID"),
                 control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.lmm.bym)
5.1.1.1.4 Buffers 750m
f <- Bike_lane_diff.by.street.2011.2016b750 ~ wSCOREMAT.2011 + Bike_lane.by.street.2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b750, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016b750 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b750 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.565 -3.039 -1.415  1.939 18.956 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.4705     0.1622   21.40   <2e-16 ***
## wSCOREMAT.2011  -5.5739     3.9538   -1.41    0.159    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.226 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.00288,    Adjusted R-squared:  0.001431 
## F-statistic: 1.987 on 1 and 688 DF,  p-value: 0.1591
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.956 -3.007 -1.099  1.912 18.009 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                    5.12282    0.32203  15.908  < 2e-16 ***
## wSCOREMAT.2011               -10.78761    3.95936  -2.725   0.0066 ** 
## Bike_lane.by.street.2011b750  -0.18232    0.03119  -5.845 7.83e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.127 on 685 degrees of freedom
## Multiple R-squared:  0.05064,    Adjusted R-squared:  0.04787 
## F-statistic: 18.27 on 2 and 685 DF,  p-value: 1.861e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 36.108, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8271125271    -0.0032693526     0.0005288817
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1273.8, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1270.6, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 8.8447, df = 1, p-value = 0.002939
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 5.6545, df = 1, p-value = 0.01741
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1279.5, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =================================================================================
##                                              Dependent variable:                 
##                              ----------------------------------------------------
##                                     Bike_lane_diff.by.street.2011.2016b750       
##                                        OLS              spatial        spatial   
##                                                      autoregressive     error    
##                                        (1)                (2)            (3)     
## ---------------------------------------------------------------------------------
## wSCOREMAT.2011                     -10.788***           -3.471**      -4.706**   
##                                      (3.959)            (1.385)        (2.009)   
##                                                                                  
## Bike_lane.by.street.2011b750        -0.182***          -0.030***      -0.051**   
##                                      (0.031)            (0.011)        (0.022)   
##                                                                                  
## Constant                            5.123***            0.450***      3.908***   
##                                      (0.322)            (0.122)        (1.174)   
##                                                                                  
## ---------------------------------------------------------------------------------
## Observations                           688                688            688     
## R2                                    0.051                                      
## Adjusted R2                           0.048                                      
## Log Likelihood                                         -1,330.041    -1,330.875  
## sigma2                                                   2.057          2.054    
## Akaike Inf. Crit.                                      2,670.082      2,671.751  
## Residual Std. Error             4.127 (df = 685)                                 
## F Statistic                  18.270*** (df = 2; 685)                             
## Wald Test (df = 1)                                   10,190.470***  10,571.780***
## LR Test (df = 1)                                      1,239.972***  1,238.303*** 
## =================================================================================
## Note:                                                 *p<0.1; **p<0.05; ***p<0.01

5.1.1.2 Canopy change

Measuring canopy (i.e. greenness ~ grass & trees) ratio within CT/buffer in 2011 (in %)

5.1.1.2.1 Census tract level
f <- pct_esp_vert_diff_2011.2017ct ~ wSCOREMAT.2011 + pct_esp_vert_2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017ct, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017ct ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017ct ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.165  -1.944  -0.273   1.524  37.029 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      4.1619     0.1313  31.687   <2e-16 ***
## wSCOREMAT.2011   1.7219     3.2020   0.538    0.591    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.423 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0004201,  Adjusted R-squared:  -0.001033 
## F-statistic: 0.2892 on 1 and 688 DF,  p-value: 0.5909
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.135  -1.693  -0.298   1.372  36.952 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          5.921007   0.339209  17.455  < 2e-16 ***
## wSCOREMAT.2011      -3.576164   3.264036  -1.096    0.274    
## pct_esp_vert_2011ct -0.046076   0.008284  -5.562 3.83e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.348 on 685 degrees of freedom
## Multiple R-squared:  0.04346,    Adjusted R-squared:  0.04067 
## F-statistic: 15.56 on 2 and 685 DF,  p-value: 2.461e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 14.655, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3335379149    -0.0032487433     0.0005281249
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 207.14, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 218.69, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 1.0324, df = 1, p-value = 0.3096
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 12.583, df = 1, p-value = 0.0003893
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 219.73, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                               pct_esp_vert_diff_2011.2017ct          
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## wSCOREMAT.2011              -3.576              -0.966       0.247   
##                             (3.264)            (2.810)      (3.790)  
##                                                                      
## pct_esp_vert_2011ct        -0.046***          -0.023***     -0.024** 
##                             (0.008)            (0.007)      (0.011)  
##                                                                      
## Constant                   5.921***            2.713***     5.093*** 
##                             (0.339)            (0.370)      (0.474)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.043                                   
## Adjusted R2                  0.041                                   
## Log Likelihood                                -1,728.072   -1,730.659
## sigma2                                          8.302        8.353   
## Akaike Inf. Crit.                             3,466.145    3,471.319 
## Residual Std. Error    3.348 (df = 685)                              
## F Statistic         15.561*** (df = 2; 685)                          
## Wald Test (df = 1)                            188.601***   190.814***
## LR Test (df = 1)                              155.985***   150.811***
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
5.1.1.2.2 Buffer 250m
f <- pct_esp_vert_diff_2011.2017b250 ~ wSCOREMAT.2011 + pct_esp_vert_2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b250, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017b250 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b250 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.827 -1.729 -0.027  1.341 34.699 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.9602     0.1125  35.192   <2e-16 ***
## wSCOREMAT.2011  -1.7145     2.7434  -0.625    0.532    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.932 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0005674,  Adjusted R-squared:  -0.0008853 
## F-statistic: 0.3906 on 1 and 688 DF,  p-value: 0.5322
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.972 -1.515 -0.196  1.088 34.781 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.972991   0.325925  18.326  < 2e-16 ***
## wSCOREMAT.2011        -7.075494   2.780314  -2.545   0.0112 *  
## pct_esp_vert_2011b250 -0.055450   0.008506  -6.519 1.37e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.846 on 685 degrees of freedom
## Multiple R-squared:  0.05917,    Adjusted R-squared:  0.05642 
## F-statistic: 21.54 on 2 and 685 DF,  p-value: 8.464e-10
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 21.585, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.4926772697    -0.0033927735     0.0005281893
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 451.97, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 463.81, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.062671, df = 1, p-value = 0.8023
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 11.91, df = 1, p-value = 0.0005582
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 463.88, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                      Dependent variable:               
##                       -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017b250         
##                                 OLS              spatial      spatial  
##                                               autoregressive   error   
##                                 (1)                (2)          (3)    
## -----------------------------------------------------------------------
## wSCOREMAT.2011               -7.075**             -2.699       -3.180  
##                               (2.780)            (2.050)      (2.906)  
##                                                                        
## pct_esp_vert_2011b250        -0.055***          -0.020***     -0.028** 
##                               (0.009)            (0.006)      (0.012)  
##                                                                        
## Constant                     5.973***            1.823***     4.947*** 
##                               (0.326)            (0.299)      (0.518)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                    688                688          688    
## R2                             0.059                                   
## Adjusted R2                    0.056                                   
## Log Likelihood                                  -1,528.015   -1,530.161
## sigma2                                            4.376        4.386   
## Akaike Inf. Crit.                               3,066.030    3,070.321 
## Residual Std. Error      2.846 (df = 685)                              
## F Statistic           21.540*** (df = 2; 685)                          
## Wald Test (df = 1)                              547.617***   570.638***
## LR Test (df = 1)                                332.733***   328.441***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
5.1.1.2.3 Buffer 500m
f <- pct_esp_vert_diff_2011.2017b500 ~ wSCOREMAT.2011 + pct_esp_vert_2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b500, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017b500 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b500 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.614 -1.542 -0.055  1.293 32.079 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.8940     0.1049  37.116   <2e-16 ***
## wSCOREMAT.2011  -1.2350     2.5576  -0.483    0.629    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.734 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0003388,  Adjusted R-squared:  -0.001114 
## F-statistic: 0.2332 on 1 and 688 DF,  p-value: 0.6293
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.820 -1.478 -0.191  1.131 32.244 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.760555   0.320053  17.999  < 2e-16 ***
## wSCOREMAT.2011        -5.773200   2.593194  -2.226   0.0263 *  
## pct_esp_vert_2011b500 -0.051377   0.008393  -6.121 1.56e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.663 on 685 degrees of freedom
## Multiple R-squared:  0.05236,    Adjusted R-squared:  0.04959 
## F-statistic: 18.92 on 2 and 685 DF,  p-value: 1.001e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 24.696, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5641616547    -0.0034364270     0.0005282399
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 592.64, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 607.14, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.045936, df = 1, p-value = 0.8303
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 14.548, df = 1, p-value = 0.0001366
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 607.18, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                      Dependent variable:               
##                       -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017b500         
##                                 OLS              spatial      spatial  
##                                               autoregressive   error   
##                                 (1)                (2)          (3)    
## -----------------------------------------------------------------------
## wSCOREMAT.2011               -5.773**             -1.621       -1.304  
##                               (2.593)            (1.726)      (2.474)  
##                                                                        
## pct_esp_vert_2011b500        -0.051***           -0.015**      -0.018  
##                               (0.008)            (0.006)      (0.012)  
##                                                                        
## Constant                     5.761***            1.353***     4.484*** 
##                               (0.320)            (0.258)      (0.541)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                    688                688          688    
## R2                             0.052                                   
## Adjusted R2                    0.050                                   
## Log Likelihood                                  -1,424.414   -1,426.701
## sigma2                                            3.129        3.137   
## Akaike Inf. Crit.                               2,858.829    2,863.402 
## Residual Std. Error      2.663 (df = 685)                              
## F Statistic           18.924*** (df = 2; 685)                          
## Wald Test (df = 1)                              917.984***   962.236***
## LR Test (df = 1)                                448.397***   443.824***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
5.1.1.2.4 Buffer 750m
f <- pct_esp_vert_diff_2011.2017b750 ~ wSCOREMAT.2011 + pct_esp_vert_2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b750, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017b750 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b750 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.6691 -1.5113 -0.0059  1.2007 29.1958 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.8425     0.1008  38.102   <2e-16 ***
## wSCOREMAT.2011  -1.7355     2.4585  -0.706     0.48    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.628 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0007238,  Adjusted R-squared:  -0.0007286 
## F-statistic: 0.4983 on 1 and 688 DF,  p-value: 0.4805
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.4595 -1.4265 -0.1844  1.1168 29.4002 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            5.611655   0.317240  17.689  < 2e-16 ***
## wSCOREMAT.2011        -5.676235   2.487251  -2.282   0.0228 *  
## pct_esp_vert_2011b750 -0.048619   0.008334  -5.834 8.36e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.566 on 685 degrees of freedom
## Multiple R-squared:  0.04827,    Adjusted R-squared:  0.04549 
## F-statistic: 17.37 on 2 and 685 DF,  p-value: 4.374e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 27.864, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6369454190    -0.0034732067     0.0005282439
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 755.42, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 769.98, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.031405, df = 1, p-value = 0.8593
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 14.594, df = 1, p-value = 0.0001333
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 770.01, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =========================================================================
##                                       Dependent variable:                
##                       ---------------------------------------------------
##                                 pct_esp_vert_diff_2011.2017b750          
##                                 OLS              spatial       spatial   
##                                               autoregressive    error    
##                                 (1)                (2)           (3)     
## -------------------------------------------------------------------------
## wSCOREMAT.2011               -5.676**             -1.219        -0.799   
##                               (2.487)            (1.471)       (2.120)   
##                                                                          
## pct_esp_vert_2011b750        -0.049***           -0.011**       -0.013   
##                               (0.008)            (0.005)       (0.012)   
##                                                                          
## Constant                     5.612***            1.000***      4.241***  
##                               (0.317)            (0.222)       (0.565)   
##                                                                          
## -------------------------------------------------------------------------
## Observations                    688                688           688     
## R2                             0.048                                     
## Adjusted R2                    0.045                                     
## Log Likelihood                                  -1,329.337    -1,331.045 
## sigma2                                            2.296         2.298    
## Akaike Inf. Crit.                               2,668.674     2,672.091  
## Residual Std. Error      2.566 (df = 685)                                
## F Statistic           17.371*** (df = 2; 685)                            
## Wald Test (df = 1)                             1,496.012***  1,571.628***
## LR Test (df = 1)                                587.290***    583.874*** 
## =========================================================================
## Note:                                         *p<0.1; **p<0.05; ***p<0.01

5.1.1.3 Canopy (trees) change

Measuring high canopy (i.e. trees only) ratio within CT/buffer in 2011 (in %)

5.1.1.3.1 Census tract level
f <- pct_esp_vert_diff_high_2011.2017ct ~ wSCOREMAT.2011 + pct_esp_vert_high_2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017ct, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017ct ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017ct ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.8508 -1.4234 -0.3206  1.1810 11.3606 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.4314     0.0846  40.560  < 2e-16 ***
## wSCOREMAT.2011 -11.9113     2.0625  -5.775 1.16e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.205 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.04624,    Adjusted R-squared:  0.04485 
## F-statistic: 33.35 on 1 and 688 DF,  p-value: 1.164e-08
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.8568 -1.4429 -0.3496  1.1375 10.8046 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               2.957131   0.197355  14.984  < 2e-16 ***
## wSCOREMAT.2011           -9.320892   2.240821  -4.160 3.59e-05 ***
## pct_esp_vert_high_2011ct  0.025076   0.009528   2.632  0.00868 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.185 on 685 degrees of freedom
## Multiple R-squared:  0.05448,    Adjusted R-squared:  0.05172 
## F-statistic: 19.74 on 2 and 685 DF,  p-value: 4.64e-09
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 23.651, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5413362250    -0.0028257960     0.0005293881
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 545.65, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 551.16, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 2.641, df = 1, p-value = 0.1041
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 8.1499, df = 1, p-value = 0.004306
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 553.8, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==========================================================================
##                                         Dependent variable:               
##                          -------------------------------------------------
##                                 pct_esp_vert_diff_high_2011.2017ct        
##                                    OLS              spatial      spatial  
##                                                  autoregressive   error   
##                                    (1)                (2)          (3)    
## --------------------------------------------------------------------------
## wSCOREMAT.2011                  -9.321***            -1.126       -0.049  
##                                  (2.241)            (1.565)      (2.129)  
##                                                                           
## pct_esp_vert_high_2011ct        0.025***            0.027***     0.041*** 
##                                  (0.010)            (0.007)      (0.008)  
##                                                                           
## Constant                        2.957***            0.411**      2.900*** 
##                                  (0.197)            (0.161)      (0.288)  
##                                                                           
## --------------------------------------------------------------------------
## Observations                       688                688          688    
## R2                                0.054                                   
## Adjusted R2                       0.052                                   
## Log Likelihood                                     -1,314.461   -1,312.230
## sigma2                                               2.316        2.290   
## Akaike Inf. Crit.                                  2,638.922    2,634.461 
## Residual Std. Error         2.185 (df = 685)                              
## F Statistic              19.736*** (df = 2; 685)                          
## Wald Test (df = 1)                                 714.453***   734.581***
## LR Test (df = 1)                                   396.333***   400.794***
## ==========================================================================
## Note:                                          *p<0.1; **p<0.05; ***p<0.01
5.1.1.3.2 Buffer 250m
f <- pct_esp_vert_diff_high_2011.2017b250 ~ wSCOREMAT.2011 + pct_esp_vert_high_2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b250, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017b250 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b250 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9628 -1.1429 -0.2624  0.8870  6.8083 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.15716    0.06809  46.369  < 2e-16 ***
## wSCOREMAT.2011 -12.18518    1.65991  -7.341 6.01e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.774 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.07264,    Adjusted R-squared:  0.07129 
## F-statistic: 53.89 on 1 and 688 DF,  p-value: 6.007e-13
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.4758 -1.1097 -0.2870  0.8766  6.7952 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  2.700422   0.184102  14.668  < 2e-16 ***
## wSCOREMAT.2011             -10.031365   1.836776  -5.461 6.61e-08 ***
## pct_esp_vert_high_2011b250   0.025849   0.009696   2.666  0.00786 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.767 on 685 degrees of freedom
## Multiple R-squared:  0.08138,    Adjusted R-squared:  0.0787 
## F-statistic: 30.34 on 2 and 685 DF,  p-value: 2.364e-13
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 33.042, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##      0.757184048     -0.003017438      0.000529320
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1067.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1074.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 10.342, df = 1, p-value = 0.001301
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 17.306, df = 1, p-value = 3.181e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1084.8, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==============================================================================
##                                            Dependent variable:                
##                            ---------------------------------------------------
##                                   pct_esp_vert_diff_high_2011.2017b250        
##                                      OLS              spatial       spatial   
##                                                    autoregressive    error    
##                                      (1)                (2)           (3)     
## ------------------------------------------------------------------------------
## wSCOREMAT.2011                   -10.031***            -1.006        -1.743   
##                                    (1.837)            (0.830)       (1.134)   
##                                                                               
## pct_esp_vert_high_2011b250        0.026***            0.017***      0.029***  
##                                    (0.010)            (0.004)       (0.006)   
##                                                                               
## Constant                          2.700***             0.040        2.976***  
##                                    (0.184)            (0.090)       (0.355)   
##                                                                               
## ------------------------------------------------------------------------------
## Observations                         688                688           688     
## R2                                  0.081                                     
## Adjusted R2                         0.079                                     
## Log Likelihood                                        -903.726      -903.135  
## sigma2                                                 0.630         0.625    
## Akaike Inf. Crit.                                    1,817.451     1,816.269  
## Residual Std. Error           1.767 (df = 685)                                
## F Statistic                30.343*** (df = 2; 685)                            
## Wald Test (df = 1)                                  3,794.041***  3,931.168***
## LR Test (df = 1)                                     925.510***    926.692*** 
## ==============================================================================
## Note:                                              *p<0.1; **p<0.05; ***p<0.01
5.1.1.3.3 Buffer 500m
f <- pct_esp_vert_diff_high_2011.2017b500 ~ wSCOREMAT.2011 + pct_esp_vert_high_2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b500, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017b500 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b500 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.0396 -1.0949 -0.2033  0.7381  7.3251 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.07086    0.06356  48.316  < 2e-16 ***
## wSCOREMAT.2011 -10.94933    1.54945  -7.067  3.9e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.656 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.06767,    Adjusted R-squared:  0.06632 
## F-statistic: 49.94 on 1 and 688 DF,  p-value: 3.902e-12
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.7926 -1.1020 -0.1826  0.6887  7.2807 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.563413   0.182458  14.049  < 2e-16 ***
## wSCOREMAT.2011             -8.673968   1.713015  -5.064  5.3e-07 ***
## pct_esp_vert_high_2011b500  0.028479   0.009654   2.950  0.00329 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.648 on 685 degrees of freedom
## Multiple R-squared:  0.07797,    Adjusted R-squared:  0.07528 
## F-statistic: 28.96 on 2 and 685 DF,  p-value: 8.416e-13
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 35.835, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8212855933    -0.0031146445     0.0005292543
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1255.9, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1267.8, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 8.7142, df = 1, p-value = 0.003157
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 20.526, df = 1, p-value = 5.881e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1276.5, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==============================================================================
##                                            Dependent variable:                
##                            ---------------------------------------------------
##                                   pct_esp_vert_diff_high_2011.2017b500        
##                                      OLS              spatial       spatial   
##                                                    autoregressive    error    
##                                      (1)                (2)           (3)     
## ------------------------------------------------------------------------------
## wSCOREMAT.2011                    -8.674***            -0.375        -0.535   
##                                    (1.713)            (0.600)       (0.821)   
##                                                                               
## pct_esp_vert_high_2011b500        0.028***            0.013***      0.024***  
##                                    (0.010)            (0.003)       (0.006)   
##                                                                               
## Constant                          2.563***             -0.034       2.943***  
##                                    (0.182)            (0.067)       (0.435)   
##                                                                               
## ------------------------------------------------------------------------------
## Observations                         688                688           688     
## R2                                  0.078                                     
## Adjusted R2                         0.075                                     
## Log Likelihood                                        -699.313      -699.664  
## sigma2                                                 0.331         0.330    
## Akaike Inf. Crit.                                    1,408.626     1,409.327  
## Residual Std. Error           1.648 (df = 685)                                
## F Statistic                28.963*** (df = 2; 685)                            
## Wald Test (df = 1)                                  8,914.158***  9,297.357***
## LR Test (df = 1)                                    1,238.174***  1,237.473***
## ==============================================================================
## Note:                                              *p<0.1; **p<0.05; ***p<0.01
5.1.1.3.4 Buffer 750m
f <- pct_esp_vert_diff_high_2011.2017b750 ~ wSCOREMAT.2011 + pct_esp_vert_high_2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b750, x=wSCOREMAT.2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017b750 ~ wSCOREMAT.2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b750 ~ wSCOREMAT.2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9569 -0.9961 -0.2127  0.7393  6.2521 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      2.99802    0.05853  51.218  < 2e-16 ***
## wSCOREMAT.2011 -10.33948    1.42699  -7.246 1.16e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.525 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0709, Adjusted R-squared:  0.06955 
## F-statistic:  52.5 on 1 and 688 DF,  p-value: 1.158e-12
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.7565 -0.9865 -0.2101  0.6964  6.2122 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.44168    0.17574  13.894  < 2e-16 ***
## wSCOREMAT.2011             -8.04374    1.57439  -5.109  4.2e-07 ***
## pct_esp_vert_high_2011b750  0.03133    0.00935   3.351 0.000849 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.516 on 685 degrees of freedom
## Multiple R-squared:  0.08511,    Adjusted R-squared:  0.08243 
## F-statistic: 31.86 on 2 and 685 DF,  p-value: 5.881e-14
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 37.195, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8524572893    -0.0031751418     0.0005291739
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1353.1, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1365.8, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 9.3906, df = 1, p-value = 0.002181
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 22.119, df = 1, p-value = 2.563e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1375.2, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ===============================================================================
##                                            Dependent variable:                 
##                            ----------------------------------------------------
##                                    pct_esp_vert_diff_high_2011.2017b750        
##                                      OLS              spatial        spatial   
##                                                    autoregressive     error    
##                                      (1)                (2)            (3)     
## -------------------------------------------------------------------------------
## wSCOREMAT.2011                    -8.044***            -0.258        -0.281    
##                                    (1.574)            (0.476)        (0.643)   
##                                                                                
## pct_esp_vert_high_2011b750        0.031***            0.011***      0.026***   
##                                    (0.009)            (0.003)        (0.005)   
##                                                                                
## Constant                          2.442***             -0.059       2.696***   
##                                    (0.176)            (0.055)        (0.459)   
##                                                                                
## -------------------------------------------------------------------------------
## Observations                         688                688            688     
## R2                                  0.085                                      
## Adjusted R2                         0.082                                      
## Log Likelihood                                        -546.616      -544.360   
## sigma2                                                 0.209          0.206    
## Akaike Inf. Crit.                                    1,103.233      1,098.721  
## Residual Std. Error           1.516 (df = 685)                                 
## F Statistic                31.860*** (df = 2; 685)                             
## Wald Test (df = 1)                                 13,692.000***  14,762.580***
## LR Test (df = 1)                                    1,428.676***  1,433.188*** 
## ===============================================================================
## Note:                                               *p<0.1; **p<0.05; ***p<0.01

5.1.2 UI vs Visible minority

5.1.2.1 Bike lane length change

Bike lane ratio to streets (in %). With or without controlling for UC in 2011.

5.1.2.1.1 Census tract level
f <- Bike_lane_diff.by.street.2011.2016ct ~ vis_minority_2011 + Bike_lane.by.street.2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016ct, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016ct ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016ct ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.758 -3.975 -3.059  0.859 38.865 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.85228    0.51159   9.485  < 2e-16 ***
## vis_minority_2011 -0.04599    0.01689  -2.723  0.00663 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.156 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.01066,    Adjusted R-squared:  0.009226 
## F-statistic: 7.416 on 1 and 688 DF,  p-value: 0.00663
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.785 -4.145 -2.844  1.412 37.913 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 6.22821    0.60194  10.347  < 2e-16 ***
## vis_minority_2011          -0.05827    0.01697  -3.434  0.00063 ***
## Bike_lane.by.street.2011ct -0.12028    0.02910  -4.134 4.01e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.079 on 685 degrees of freedom
## Multiple R-squared:  0.0352, Adjusted R-squared:  0.03238 
## F-statistic:  12.5 on 2 and 685 DF,  p-value: 4.674e-06
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 15.977, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3649188740    -0.0026803724     0.0005293925
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 248.11, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 261.73, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 3.0292, df = 1, p-value = 0.08178
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 16.65, df = 1, p-value = 4.495e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 264.76, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ============================================================================
##                                           Dependent variable:               
##                            -------------------------------------------------
##                                  Bike_lane_diff.by.street.2011.2016ct       
##                                      OLS              spatial      spatial  
##                                                    autoregressive   error   
##                                      (1)                (2)          (3)    
## ----------------------------------------------------------------------------
## vis_minority_2011                 -0.058***           -0.032**      -0.033  
##                                    (0.017)            (0.014)      (0.020)  
##                                                                             
## Bike_lane.by.street.2011ct        -0.120***          -0.064***     -0.053** 
##                                    (0.029)            (0.024)      (0.027)  
##                                                                             
## Constant                          6.228***            2.824***     5.147*** 
##                                    (0.602)            (0.534)      (0.842)  
##                                                                             
## ----------------------------------------------------------------------------
## Observations                         688                688          688    
## R2                                  0.035                                   
## Adjusted R2                         0.032                                   
## Log Likelihood                                       -2,224.180   -2,226.230
## sigma2                                                 34.469       34.618  
## Akaike Inf. Crit.                                    4,458.359    4,462.459 
## Residual Std. Error           7.079 (df = 685)                              
## F Statistic                12.496*** (df = 2; 685)                          
## Wald Test (df = 1)                                   272.808***   277.851***
## LR Test (df = 1)                                     194.181***   190.081***
## ============================================================================
## Note:                                            *p<0.1; **p<0.05; ***p<0.01
5.1.2.1.2 Buffers 250m
f <- Bike_lane_diff.by.street.2011.2016b250 ~ vis_minority_2011 + Bike_lane.by.street.2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b250, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016b250 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b250 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.625  -3.447  -2.147   1.972  27.232 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.86710    0.38548  12.626  < 2e-16 ***
## vis_minority_2011 -0.05521    0.01273  -4.338 1.65e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.392 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.02662,    Adjusted R-squared:  0.02521 
## F-statistic: 18.82 on 1 and 688 DF,  p-value: 1.655e-05
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.893  -3.511  -1.533   2.052  24.777 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   7.61250    0.51282  14.844  < 2e-16 ***
## vis_minority_2011            -0.08244    0.01271  -6.483 1.72e-10 ***
## Bike_lane.by.street.2011b250 -0.23281    0.03054  -7.623 8.31e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.179 on 685 degrees of freedom
## Multiple R-squared:  0.1039, Adjusted R-squared:  0.1013 
## F-statistic: 39.71 on 2 and 685 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 26.999, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6179214311    -0.0030629649     0.0005290302
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 711.41, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 734.27, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 2.4955, df = 1, p-value = 0.1142
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 25.348, df = 1, p-value = 4.786e-07
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 736.76, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ================================================================================
##                                              Dependent variable:                
##                              ---------------------------------------------------
##                                    Bike_lane_diff.by.street.2011.2016b250       
##                                        OLS              spatial       spatial   
##                                                      autoregressive    error    
##                                        (1)                (2)           (3)     
## --------------------------------------------------------------------------------
## vis_minority_2011                   -0.082***          -0.033***     -0.037***  
##                                      (0.013)            (0.007)       (0.012)   
##                                                                                 
## Bike_lane.by.street.2011b250        -0.233***          -0.081***     -0.084***  
##                                      (0.031)            (0.018)       (0.026)   
##                                                                                 
## Constant                            7.612***            2.077***      5.627***  
##                                      (0.513)            (0.325)       (0.963)   
##                                                                                 
## --------------------------------------------------------------------------------
## Observations                           688                688           688     
## R2                                    0.104                                     
## Adjusted R2                           0.101                                     
## Log Likelihood                                         -1,799.172    -1,805.239 
## sigma2                                                   8.861         8.942    
## Akaike Inf. Crit.                                      3,608.345     3,620.478  
## Residual Std. Error             5.179 (df = 685)                                
## F Statistic                  39.713*** (df = 2; 685)                            
## Wald Test (df = 1)                                    1,966.109***  2,112.762***
## LR Test (df = 1)                                       614.092***    601.959*** 
## ================================================================================
## Note:                                                *p<0.1; **p<0.05; ***p<0.01
5.1.2.1.3 Buffers 500m
f <- Bike_lane_diff.by.street.2011.2016b500 ~ vis_minority_2011 + Bike_lane.by.street.2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b500, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016b500 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b500 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -8.704 -3.241 -1.655  2.003 18.311 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.59890    0.33235  13.837  < 2e-16 ***
## vis_minority_2011 -0.04575    0.01097  -4.169 3.45e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.649 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.02464,    Adjusted R-squared:  0.02323 
## F-statistic: 17.38 on 1 and 688 DF,  p-value: 3.446e-05
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.229 -3.233 -1.224  1.908 18.346 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   7.22642    0.48215  14.988  < 2e-16 ***
## vis_minority_2011            -0.07074    0.01110  -6.371 3.44e-10 ***
## Bike_lane.by.street.2011b500 -0.22424    0.03128  -7.169 1.97e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.481 on 685 degrees of freedom
## Multiple R-squared:  0.09409,    Adjusted R-squared:  0.09145 
## F-statistic: 35.57 on 2 and 685 DF,  p-value: 2e-15
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 32.98, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7552282090    -0.0032172255     0.0005288574
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1062.7, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1075.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 7.9585, df = 1, p-value = 0.004786
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 20.773, df = 1, p-value = 5.171e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1083.5, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ================================================================================
##                                              Dependent variable:                
##                              ---------------------------------------------------
##                                    Bike_lane_diff.by.street.2011.2016b500       
##                                        OLS              spatial       spatial   
##                                                      autoregressive    error    
##                                        (1)                (2)           (3)     
## --------------------------------------------------------------------------------
## vis_minority_2011                   -0.071***          -0.024***     -0.032***  
##                                      (0.011)            (0.005)       (0.008)   
##                                                                                 
## Bike_lane.by.street.2011b500        -0.224***          -0.055***     -0.073***  
##                                      (0.031)            (0.014)       (0.023)   
##                                                                                 
## Constant                            7.226***            1.358***      5.088***  
##                                      (0.482)            (0.224)       (1.097)   
##                                                                                 
## --------------------------------------------------------------------------------
## Observations                           688                688           688     
## R2                                    0.094                                     
## Adjusted R2                           0.091                                     
## Log Likelihood                                         -1,516.906    -1,520.036 
## sigma2                                                   3.671         3.669    
## Akaike Inf. Crit.                                      3,043.812     3,050.072  
## Residual Std. Error             4.481 (df = 685)                                
## F Statistic                  35.574*** (df = 2; 685)                            
## Wald Test (df = 1)                                    5,248.139***  5,824.321***
## LR Test (df = 1)                                       979.557***    973.298*** 
## ================================================================================
## Note:                                                *p<0.1; **p<0.05; ***p<0.01
5.1.2.1.4 Buffers 750m
f <- Bike_lane_diff.by.street.2011.2016b750 ~ vis_minority_2011 + Bike_lane.by.street.2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b750, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(Bike_lane_diff.by.street.2011.2016b750 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b750 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.988 -3.000 -1.417  1.921 18.327 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.45024    0.29897  14.885  < 2e-16 ***
## vis_minority_2011 -0.04016    0.00987  -4.068 5.29e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.182 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.02349,    Adjusted R-squared:  0.02207 
## F-statistic: 16.55 on 1 and 688 DF,  p-value: 5.286e-05
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.988 -2.917 -1.016  1.840 16.848 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   7.08647    0.46148  15.356  < 2e-16 ***
## vis_minority_2011            -0.06404    0.01005  -6.373 3.40e-10 ***
## Bike_lane.by.street.2011b750 -0.22754    0.03154  -7.215 1.44e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.032 on 685 degrees of freedom
## Multiple R-squared:  0.09365,    Adjusted R-squared:  0.091 
## F-statistic: 35.39 on 2 and 685 DF,  p-value: 2.369e-15
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 35.615, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8156017948    -0.0033075186     0.0005286986
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1239.4, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1251.2, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 9.6552, df = 1, p-value = 0.001888
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 21.413, df = 1, p-value = 3.703e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1260.8, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =================================================================================
##                                              Dependent variable:                 
##                              ----------------------------------------------------
##                                     Bike_lane_diff.by.street.2011.2016b750       
##                                        OLS              spatial        spatial   
##                                                      autoregressive     error    
##                                        (1)                (2)            (3)     
## ---------------------------------------------------------------------------------
## vis_minority_2011                   -0.064***          -0.018***      -0.025***  
##                                      (0.010)            (0.004)        (0.006)   
##                                                                                  
## Bike_lane.by.street.2011b750        -0.228***          -0.043***      -0.055**   
##                                      (0.032)            (0.011)        (0.022)   
##                                                                                  
## Constant                            7.086***            1.032***      4.535***   
##                                      (0.461)            (0.175)        (1.158)   
##                                                                                  
## ---------------------------------------------------------------------------------
## Observations                           688                688            688     
## R2                                    0.094                                      
## Adjusted R2                           0.091                                      
## Log Likelihood                                         -1,319.138    -1,323.066  
## sigma2                                                   2.006          2.010    
## Akaike Inf. Crit.                                      2,648.275      2,656.133  
## Residual Std. Error             4.032 (df = 685)                                 
## F Statistic                  35.388*** (df = 2; 685)                             
## Wald Test (df = 1)                                    9,167.488***  10,346.600***
## LR Test (df = 1)                                      1,229.711***  1,221.854*** 
## =================================================================================
## Note:                                                 *p<0.1; **p<0.05; ***p<0.01

5.1.2.2 Canopy change

Measuring canopy (i.e. greenness ~ grass & trees) ratio within CT/buffer in 2011 (in %)

5.1.2.2.1 Census tract level
f <- pct_esp_vert_diff_2011.2017ct ~ vis_minority_2011 + pct_esp_vert_2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017ct, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017ct ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017ct ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.093  -1.938  -0.199   1.553  36.892 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.257351   0.244837   17.39   <2e-16 ***
## vis_minority_2011 -0.004040   0.008083   -0.50    0.617    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.425 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.000363,   Adjusted R-squared:  -0.00109 
## F-statistic: 0.2498 on 1 and 688 DF,  p-value: 0.6174
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.334  -1.772  -0.313   1.363  36.751 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          6.228029   0.423389  14.710  < 2e-16 ***
## vis_minority_2011   -0.014721   0.008116  -1.814   0.0702 .  
## pct_esp_vert_2011ct -0.045201   0.008149  -5.547 4.15e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.35 on 685 degrees of freedom
## Multiple R-squared:  0.04353,    Adjusted R-squared:  0.04073 
## F-statistic: 15.59 on 2 and 685 DF,  p-value: 2.401e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 14.34, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3260896247    -0.0033389237     0.0005277756
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 198.12, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 212.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 2.7017, df = 1, p-value = 0.1002
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 17.086, df = 1, p-value = 3.573e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 215.21, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =====================================================================
##                                    Dependent variable:               
##                     -------------------------------------------------
##                               pct_esp_vert_diff_2011.2017ct          
##                               OLS              spatial      spatial  
##                                             autoregressive   error   
##                               (1)                (2)          (3)    
## ---------------------------------------------------------------------
## vis_minority_2011           -0.015*            -0.0003       0.012   
##                             (0.008)            (0.007)      (0.010)  
##                                                                      
## pct_esp_vert_2011ct        -0.045***          -0.022***     -0.020*  
##                             (0.008)            (0.007)      (0.010)  
##                                                                      
## Constant                   6.228***            2.631***     4.611*** 
##                             (0.423)            (0.428)      (0.577)  
##                                                                      
## ---------------------------------------------------------------------
## Observations                  688                688          688    
## R2                           0.044                                   
## Adjusted R2                  0.041                                   
## Log Likelihood                                -1,729.191   -1,730.846
## sigma2                                          8.322        8.329   
## Akaike Inf. Crit.                             3,468.382    3,471.693 
## Residual Std. Error    3.350 (df = 685)                              
## F Statistic         15.586*** (df = 2; 685)                          
## Wald Test (df = 1)                            191.450***   205.130***
## LR Test (df = 1)                              154.489***   151.178***
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
5.1.2.2.2 Buffer 250m
f <- pct_esp_vert_diff_2011.2017b250 ~ vis_minority_2011 + pct_esp_vert_2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b250, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017b250 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b250 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.745 -1.678 -0.043  1.310 34.485 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.253273   0.209119  20.339   <2e-16 ***
## vis_minority_2011 -0.011863   0.006904  -1.718   0.0862 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.925 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.004273,   Adjusted R-squared:  0.002825 
## F-statistic: 2.952 on 1 and 688 DF,  p-value: 0.08621
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.594 -1.591 -0.142  1.143 34.523 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            6.437520   0.387538  16.611  < 2e-16 ***
## vis_minority_2011     -0.021562   0.006852  -3.147  0.00172 ** 
## pct_esp_vert_2011b250 -0.054101   0.008285  -6.530 1.28e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.838 on 685 degrees of freedom
## Multiple R-squared:  0.0632, Adjusted R-squared:  0.06047 
## F-statistic: 23.11 on 2 and 685 DF,  p-value: 1.944e-10
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 21.131, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.4819922533    -0.0034854414     0.0005278472
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 432.85, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 450.07, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.1963, df = 1, p-value = 0.6577
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 17.421, df = 1, p-value = 2.995e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 450.27, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                      Dependent variable:               
##                       -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017b250         
##                                 OLS              spatial      spatial  
##                                               autoregressive   error   
##                                 (1)                (2)          (3)    
## -----------------------------------------------------------------------
## vis_minority_2011            -0.022***            -0.003       0.002   
##                               (0.007)            (0.005)      (0.008)  
##                                                                        
## pct_esp_vert_2011b250        -0.054***          -0.018***     -0.024** 
##                               (0.008)            (0.006)      (0.012)  
##                                                                        
## Constant                     6.438***            1.818***     4.711*** 
##                               (0.388)            (0.337)      (0.580)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                    688                688          688    
## R2                             0.063                                   
## Adjusted R2                    0.060                                   
## Log Likelihood                                  -1,528.841   -1,530.841
## sigma2                                            4.386        4.391   
## Akaike Inf. Crit.                               3,067.682    3,071.683 
## Residual Std. Error      2.838 (df = 685)                              
## F Statistic           23.107*** (df = 2; 685)                          
## Wald Test (df = 1)                              546.557***   578.844***
## LR Test (df = 1)                                327.209***   323.209***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
5.1.2.2.3 Buffer 500m
f <- pct_esp_vert_diff_2011.2017b500 ~ vis_minority_2011 + pct_esp_vert_2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b500, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017b500 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b500 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.352 -1.594 -0.054  1.310 31.816 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.225329   0.194825  21.688   <2e-16 ***
## vis_minority_2011 -0.013070   0.006432  -2.032   0.0425 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.725 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.005966,   Adjusted R-squared:  0.004521 
## F-statistic: 4.129 on 1 and 688 DF,  p-value: 0.04253
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.507 -1.498 -0.205  1.210 31.958 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            6.257442   0.371569  16.841  < 2e-16 ***
## vis_minority_2011     -0.020847   0.006370  -3.273  0.00112 ** 
## pct_esp_vert_2011b500 -0.051118   0.008146  -6.275 6.18e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.65 on 685 degrees of freedom
## Multiple R-squared:  0.06068,    Adjusted R-squared:  0.05793 
## F-statistic: 22.12 on 2 and 685 DF,  p-value: 4.887e-10
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 24.269, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5540707965    -0.0035353929     0.0005278788
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 571.99, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 590.93, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.27213, df = 1, p-value = 0.6019
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 19.219, df = 1, p-value = 1.166e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 591.21, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                      Dependent variable:               
##                       -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017b500         
##                                 OLS              spatial      spatial  
##                                               autoregressive   error   
##                                 (1)                (2)          (3)    
## -----------------------------------------------------------------------
## vis_minority_2011            -0.021***            -0.002       0.001   
##                               (0.006)            (0.004)      (0.007)  
##                                                                        
## pct_esp_vert_2011b500        -0.051***           -0.014**      -0.017  
##                               (0.008)            (0.006)      (0.012)  
##                                                                        
## Constant                     6.257***            1.373***     4.416*** 
##                               (0.372)            (0.289)      (0.584)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                    688                688          688    
## R2                             0.061                                   
## Adjusted R2                    0.058                                   
## Log Likelihood                                  -1,424.706   -1,426.817
## sigma2                                            3.133        3.137   
## Akaike Inf. Crit.                               2,859.412    2,863.634 
## Residual Std. Error      2.650 (df = 685)                              
## F Statistic           22.124*** (df = 2; 685)                          
## Wald Test (df = 1)                              912.058***   964.275***
## LR Test (df = 1)                                441.193***   436.971***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
5.1.2.2.4 Buffer 750m
f <- pct_esp_vert_diff_2011.2017b750 ~ vis_minority_2011 + pct_esp_vert_2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b750, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_2011.2017b750 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b750 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.6430 -1.5699 -0.0092  1.2938 28.8848 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.242668   0.186996   22.69   <2e-16 ***
## vis_minority_2011 -0.015868   0.006174   -2.57   0.0104 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.616 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.009511,   Adjusted R-squared:  0.008071 
## F-statistic: 6.606 on 1 and 688 DF,  p-value: 0.01037
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.6344 -1.4092 -0.1755  1.1110 29.0765 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            6.151855   0.362815  16.956  < 2e-16 ***
## vis_minority_2011     -0.022345   0.006107  -3.659 0.000273 ***
## pct_esp_vert_2011b750 -0.048493   0.008081  -6.001 3.18e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.549 on 685 degrees of freedom
## Multiple R-squared:  0.05986,    Adjusted R-squared:  0.05712 
## F-statistic: 21.81 on 2 and 685 DF,  p-value: 6.583e-10
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 27.391, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6257393240    -0.0035753145     0.0005278674
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 729.53, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 750.34, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.21156, df = 1, p-value = 0.6456
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 21.02, df = 1, p-value = 4.545e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 750.55, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =========================================================================
##                                       Dependent variable:                
##                       ---------------------------------------------------
##                                 pct_esp_vert_diff_2011.2017b750          
##                                 OLS              spatial       spatial   
##                                               autoregressive    error    
##                                 (1)                (2)           (3)     
## -------------------------------------------------------------------------
## vis_minority_2011            -0.022***            -0.002        0.001    
##                               (0.006)            (0.004)       (0.006)   
##                                                                          
## pct_esp_vert_2011b750        -0.048***           -0.010**       -0.012   
##                               (0.008)            (0.005)       (0.012)   
##                                                                          
## Constant                     6.152***            1.025***      4.173***  
##                               (0.363)            (0.247)       (0.596)   
##                                                                          
## -------------------------------------------------------------------------
## Observations                    688                688           688     
## R2                             0.060                                     
## Adjusted R2                    0.057                                     
## Log Likelihood                                  -1,329.552    -1,331.114 
## sigma2                                            2.298         2.298    
## Akaike Inf. Crit.                               2,669.103     2,672.227  
## Residual Std. Error      2.549 (df = 685)                                
## F Statistic           21.808*** (df = 2; 685)                            
## Wald Test (df = 1)                             1,484.499***  1,576.539***
## LR Test (df = 1)                                578.034***    574.910*** 
## =========================================================================
## Note:                                         *p<0.1; **p<0.05; ***p<0.01

5.1.2.3 Canopy (trees) change

Measuring high canopy (i.e. trees only) ratio within CT/buffer in 2011 (in %)

5.1.2.3.1 Census tract level
f <- pct_esp_vert_diff_high_2011.2017ct ~ vis_minority_2011 + pct_esp_vert_high_2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017ct, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017ct ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017ct ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.7482 -1.5184 -0.2624  1.1531 10.7915 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.990009   0.159253  25.055  < 2e-16 ***
## vis_minority_2011 -0.024453   0.005258  -4.651 3.96e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.228 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.03048,    Adjusted R-squared:  0.02907 
## F-statistic: 21.63 on 1 and 688 DF,  p-value: 3.964e-06
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.7687 -1.4935 -0.3492  1.1044 10.2970 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               3.214924   0.250338  12.842  < 2e-16 ***
## vis_minority_2011        -0.019428   0.005330  -3.645 0.000287 ***
## pct_esp_vert_high_2011ct  0.035290   0.008988   3.926 9.49e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.194 on 685 degrees of freedom
## Multiple R-squared:  0.05138,    Adjusted R-squared:  0.04861 
## F-statistic: 18.55 on 2 and 685 DF,  p-value: 1.427e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 24.051, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5500184225    -0.0030210554     0.0005287526
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 563.65, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 560.09, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 6.3431, df = 1, p-value = 0.01178
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 2.7838, df = 1, p-value = 0.09522
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 566.43, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==========================================================================
##                                         Dependent variable:               
##                          -------------------------------------------------
##                                 pct_esp_vert_diff_high_2011.2017ct        
##                                    OLS              spatial      spatial  
##                                                  autoregressive   error   
##                                    (1)                (2)          (3)    
## --------------------------------------------------------------------------
## vis_minority_2011               -0.019***            -0.006       -0.005  
##                                  (0.005)            (0.004)      (0.006)  
##                                                                           
## pct_esp_vert_high_2011ct        0.035***            0.028***     0.041*** 
##                                  (0.009)            (0.006)      (0.008)  
##                                                                           
## Constant                        3.215***            0.562***     3.005*** 
##                                  (0.250)            (0.197)      (0.339)  
##                                                                           
## --------------------------------------------------------------------------
## Observations                       688                688          688    
## R2                                0.051                                   
## Adjusted R2                       0.049                                   
## Log Likelihood                                     -1,318.335   -1,317.115
## sigma2                                               2.349        2.331   
## Akaike Inf. Crit.                                  2,646.669    2,644.229 
## Residual Std. Error         2.194 (df = 685)                              
## F Statistic              18.550*** (df = 2; 685)                          
## Wald Test (df = 1)                                 682.328***   695.727***
## LR Test (df = 1)                                   393.823***   396.263***
## ==========================================================================
## Note:                                          *p<0.1; **p<0.05; ***p<0.01
5.1.2.3.2 Buffer 250m
f <- pct_esp_vert_diff_high_2011.2017b250 ~ vis_minority_2011 + pct_esp_vert_high_2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b250, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017b250 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b250 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.0818 -1.2094 -0.2710  0.9444  6.9013 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.657494   0.129117  28.327  < 2e-16 ***
## vis_minority_2011 -0.021890   0.004263  -5.135 3.67e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.806 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.03691,    Adjusted R-squared:  0.03551 
## F-statistic: 26.37 on 1 and 688 DF,  p-value: 3.673e-07
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1559 -1.1624 -0.2800  0.7993  6.8147 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.850601   0.217856  13.085  < 2e-16 ***
## vis_minority_2011          -0.017922   0.004300  -4.168 3.46e-05 ***
## pct_esp_vert_high_2011b250  0.040934   0.008982   4.557 6.14e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.781 on 685 degrees of freedom
## Multiple R-squared:  0.06494,    Adjusted R-squared:  0.06221 
## F-statistic: 23.78 on 2 and 685 DF,  p-value: 1.031e-10
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 33.713, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7719428311    -0.0032172811     0.0005286729
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1110.3, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1109.6, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 9.8539, df = 1, p-value = 0.001695
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 9.2119, df = 1, p-value = 0.002404
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1119.5, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==============================================================================
##                                            Dependent variable:                
##                            ---------------------------------------------------
##                                   pct_esp_vert_diff_high_2011.2017b250        
##                                      OLS              spatial       spatial   
##                                                    autoregressive    error    
##                                      (1)                (2)           (3)     
## ------------------------------------------------------------------------------
## vis_minority_2011                 -0.018***           -0.004*        -0.004   
##                                    (0.004)            (0.002)       (0.003)   
##                                                                               
## pct_esp_vert_high_2011b250        0.041***            0.018***      0.030***  
##                                    (0.009)            (0.004)       (0.006)   
##                                                                               
## Constant                          2.851***             0.117        3.043***  
##                                    (0.218)            (0.105)       (0.367)   
##                                                                               
## ------------------------------------------------------------------------------
## Observations                         688                688           688     
## R2                                  0.065                                     
## Adjusted R2                         0.062                                     
## Log Likelihood                                        -903.828      -904.773  
## sigma2                                                 0.631         0.628    
## Akaike Inf. Crit.                                    1,817.656     1,819.547  
## Residual Std. Error           1.781 (df = 685)                                
## F Statistic                23.785*** (df = 2; 685)                            
## Wald Test (df = 1)                                  3,709.127***  3,851.714***
## LR Test (df = 1)                                     935.884***    933.994*** 
## ==============================================================================
## Note:                                              *p<0.1; **p<0.05; ***p<0.01
5.1.2.3.3 Buffer 500m
f <- pct_esp_vert_diff_high_2011.2017b500 ~ vis_minority_2011 + pct_esp_vert_high_2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b500, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017b500 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b500 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.2936 -1.1328 -0.2707  0.8096  7.3055 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.474949   0.120735  28.782  < 2e-16 ***
## vis_minority_2011 -0.017844   0.003986  -4.477 8.87e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.689 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0283, Adjusted R-squared:  0.02689 
## F-statistic: 20.04 on 1 and 688 DF,  p-value: 8.873e-06
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.4107 -1.0801 -0.2125  0.7470  7.1986 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.629183   0.207718  12.657  < 2e-16 ***
## vis_minority_2011          -0.014479   0.003982  -3.636 0.000298 ***
## pct_esp_vert_high_2011b500  0.043714   0.008884   4.921 1.08e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.661 on 685 degrees of freedom
## Multiple R-squared:  0.06073,    Adjusted R-squared:  0.05799 
## F-statistic: 22.15 on 2 and 685 DF,  p-value: 4.786e-10
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 36.464, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8350260006    -0.0033161534     0.0005285917
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1299.1, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1302.5, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 7.5572, df = 1, p-value = 0.005977
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 10.967, df = 1, p-value = 0.0009277
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1310.1, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==============================================================================
##                                            Dependent variable:                
##                            ---------------------------------------------------
##                                   pct_esp_vert_diff_high_2011.2017b500        
##                                      OLS              spatial       spatial   
##                                                    autoregressive    error    
##                                      (1)                (2)           (3)     
## ------------------------------------------------------------------------------
## vis_minority_2011                 -0.014***            -0.002        -0.001   
##                                    (0.004)            (0.001)       (0.002)   
##                                                                               
## pct_esp_vert_high_2011b500        0.044***            0.013***      0.024***  
##                                    (0.009)            (0.003)       (0.006)   
##                                                                               
## Constant                          2.629***             0.006        2.950***  
##                                    (0.208)            (0.075)       (0.439)   
##                                                                               
## ------------------------------------------------------------------------------
## Observations                         688                688           688     
## R2                                  0.061                                     
## Adjusted R2                         0.058                                     
## Log Likelihood                                        -699.465      -700.520  
## sigma2                                                 0.332         0.331    
## Akaike Inf. Crit.                                    1,408.930     1,411.040  
## Residual Std. Error           1.661 (df = 685)                                
## F Statistic                22.147*** (df = 2; 685)                            
## Wald Test (df = 1)                                  8,650.187***  9,171.772***
## LR Test (df = 1)                                    1,248.939***  1,246.829***
## ==============================================================================
## Note:                                              *p<0.1; **p<0.05; ***p<0.01
5.1.2.3.4 Buffer 750m
f <- pct_esp_vert_diff_high_2011.2017b750 ~ vis_minority_2011 + pct_esp_vert_high_2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b750, x=vis_minority_2011)) +
  geom_point() +
  geom_smooth(method=lm)

res.lm <- lm(pct_esp_vert_diff_high_2011.2017b750 ~ vis_minority_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b750 ~ vis_minority_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1753 -1.0349 -0.2860  0.7644  6.2564 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.347398   0.111550  30.008  < 2e-16 ***
## vis_minority_2011 -0.015569   0.003683  -4.228 2.68e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.56 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.02532,    Adjusted R-squared:  0.0239 
## F-statistic: 17.87 on 1 and 688 DF,  p-value: 2.681e-05
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.3425 -1.0303 -0.2456  0.7005  6.1499 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.461027   0.195328  12.599  < 2e-16 ***
## vis_minority_2011          -0.012770   0.003654  -3.495 0.000505 ***
## pct_esp_vert_high_2011b750  0.046909   0.008587   5.463 6.57e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.53 on 685 degrees of freedom
## Multiple R-squared:  0.0656, Adjusted R-squared:  0.06287 
## F-statistic: 24.05 on 2 and 685 DF,  p-value: 8.084e-11
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 37.809, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8658079049    -0.0033824149     0.0005284931
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1396.7, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1401.4, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 7.2668, df = 1, p-value = 0.007024
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 12.018, df = 1, p-value = 0.000527
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1408.7, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ===============================================================================
##                                            Dependent variable:                 
##                            ----------------------------------------------------
##                                    pct_esp_vert_diff_high_2011.2017b750        
##                                      OLS              spatial        spatial   
##                                                    autoregressive     error    
##                                      (1)                (2)            (3)     
## -------------------------------------------------------------------------------
## vis_minority_2011                 -0.013***            -0.001         0.001    
##                                    (0.004)            (0.001)        (0.002)   
##                                                                                
## pct_esp_vert_high_2011b750        0.047***            0.011***      0.027***   
##                                    (0.009)            (0.003)        (0.005)   
##                                                                                
## Constant                          2.461***             -0.041       2.671***   
##                                    (0.195)            (0.060)        (0.463)   
##                                                                                
## -------------------------------------------------------------------------------
## Observations                         688                688            688     
## R2                                  0.066                                      
## Adjusted R2                         0.063                                      
## Log Likelihood                                        -546.082      -543.862   
## sigma2                                                 0.208          0.205    
## Akaike Inf. Crit.                                    1,102.165      1,097.724  
## Residual Std. Error           1.530 (df = 685)                                 
## F Statistic                24.045*** (df = 2; 685)                             
## Wald Test (df = 1)                                 13,474.780***  14,798.650***
## LR Test (df = 1)                                    1,442.505***  1,446.946*** 
## ===============================================================================
## Note:                                               *p<0.1; **p<0.05; ***p<0.01

5.1.3 UI vs gentrified CT

Gentrified CT between 2011 and 2016

5.1.3.1 Bike lane length change

Bike lane ratio to streets (in %)

5.1.3.1.1 Census tract level
f <- Bike_lane_diff.by.street.2011.2016ct ~ gentrified_2016_2011 + Bike_lane.by.street.2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016ct, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane_diff.by.street.2011.2016ct, na.rm = TRUE),
    sd = sd(Bike_lane_diff.by.street.2011.2016ct, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(Bike_lane_diff.by.street.2011.2016ct ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1    834   833.8   16.46 5.54e-05 ***
## Residuals            686  34749    50.7                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(Bike_lane_diff.by.street.2011.2016ct ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016ct ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.724 -2.947 -2.947  0.662 39.191 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.9468     0.3238   9.101  < 2e-16 ***
## gentrified_2016_2011TRUE   2.4092     0.5897   4.085 4.92e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.109 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.02368,    Adjusted R-squared:  0.02226 
## F-statistic: 16.69 on 1 and 688 DF,  p-value: 4.921e-05
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.911 -3.864 -2.682  1.093 38.277 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 3.86396    0.40815   9.467  < 2e-16 ***
## gentrified_2016_2011TRUE    2.37807    0.58573   4.060 5.47e-05 ***
## Bike_lane.by.street.2011ct -0.10331    0.02863  -3.609  0.00033 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.056 on 685 degrees of freedom
## Multiple R-squared:  0.04165,    Adjusted R-squared:  0.03885 
## F-statistic: 14.88 on 2 and 685 DF,  p-value: 4.701e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 14.731, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3368485576    -0.0022045288     0.0005297285
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 211.41, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 240.63, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 15.307, df = 1, p-value = 9.136e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 44.523, df = 1, p-value = 2.513e-11
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 255.93, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ============================================================================
##                                           Dependent variable:               
##                            -------------------------------------------------
##                                  Bike_lane_diff.by.street.2011.2016ct       
##                                      OLS              spatial      spatial  
##                                                    autoregressive   error   
##                                      (1)                (2)          (3)    
## ----------------------------------------------------------------------------
## gentrified_2016_2011              2.378***             0.627        -0.140  
##                                    (0.586)            (0.489)      (0.537)  
##                                                                             
## Bike_lane.by.street.2011ct        -0.103***           -0.055**     -0.051*  
##                                    (0.029)            (0.024)      (0.027)  
##                                                                             
## Constant                          3.864***            1.745***     4.323*** 
##                                    (0.408)            (0.373)      (0.680)  
##                                                                             
## ----------------------------------------------------------------------------
## Observations                         688                688          688    
## R2                                  0.042                                   
## Adjusted R2                         0.039                                   
## Log Likelihood                                       -2,225.914   -2,227.465
## sigma2                                                 34.663       34.635  
## Akaike Inf. Crit.                                    4,461.827    4,464.929 
## Residual Std. Error           7.056 (df = 685)                              
## F Statistic                14.885*** (df = 2; 685)                          
## Wald Test (df = 1)                                   269.551***   294.295***
## LR Test (df = 1)                                     186.099***   182.997***
## ============================================================================
## Note:                                            *p<0.1; **p<0.05; ***p<0.01
5.1.3.1.2 Buffers 250m
f <- Bike_lane_diff.by.street.2011.2016b250 ~ gentrified_2016_2011 + Bike_lane.by.street.2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b250, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane_diff.by.street.2011.2016b250, na.rm = TRUE),
    sd = sd(Bike_lane_diff.by.street.2011.2016b250, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(Bike_lane_diff.by.street.2011.2016b250 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1   1110  1109.7   39.25 6.58e-10 ***
## Residuals            686  19394    28.3                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(Bike_lane_diff.by.street.2011.2016b250 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b250 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.617  -2.613  -2.285   1.770  26.114 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.6134     0.2420  10.798  < 2e-16 ***
## gentrified_2016_2011TRUE   2.7811     0.4408   6.309 5.03e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.314 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.05469,    Adjusted R-squared:  0.05332 
## F-statistic:  39.8 on 1 and 688 DF,  p-value: 5.027e-10
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.361  -3.313  -1.549   1.757  24.799 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   4.20396    0.34815  12.075  < 2e-16 ***
## gentrified_2016_2011TRUE      2.78445    0.42996   6.476 1.80e-10 ***
## Bike_lane.by.street.2011b250 -0.18137    0.02944  -6.161 1.23e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.179 on 685 degrees of freedom
## Multiple R-squared:  0.1038, Adjusted R-squared:  0.1012 
## F-statistic: 39.66 on 2 and 685 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 25.418, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5821647436    -0.0026062168     0.0005292966
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 631.46, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 689.8, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.18178, df = 1, p-value = 0.6698
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 58.521, df = 1, p-value = 2.01e-14
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 689.98, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ================================================================================
##                                              Dependent variable:                
##                              ---------------------------------------------------
##                                    Bike_lane_diff.by.street.2011.2016b250       
##                                        OLS              spatial       spatial   
##                                                      autoregressive    error    
##                                        (1)                (2)           (3)     
## --------------------------------------------------------------------------------
## gentrified_2016_2011                2.784***            0.542**        0.189    
##                                      (0.430)            (0.250)       (0.272)   
##                                                                                 
## Bike_lane.by.street.2011b250        -0.181***          -0.060***     -0.074***  
##                                      (0.029)            (0.017)       (0.026)   
##                                                                                 
## Constant                            4.204***            0.886***      4.493***  
##                                      (0.348)            (0.223)       (0.941)   
##                                                                                 
## --------------------------------------------------------------------------------
## Observations                           688                688           688     
## R2                                    0.104                                     
## Adjusted R2                           0.101                                     
## Log Likelihood                                         -1,806.519    -1,810.056 
## sigma2                                                   9.034         9.036    
## Akaike Inf. Crit.                                      3,623.037     3,630.112  
## Residual Std. Error             5.179 (df = 685)                                
## F Statistic                  39.664*** (df = 2; 685)                            
## Wald Test (df = 1)                                    2,004.795***  2,233.463***
## LR Test (df = 1)                                       599.489***    592.414*** 
## ================================================================================
## Note:                                                *p<0.1; **p<0.05; ***p<0.01
5.1.3.1.3 Buffers 500m
f <- Bike_lane_diff.by.street.2011.2016b500 ~ gentrified_2016_2011 + Bike_lane.by.street.2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b500, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane_diff.by.street.2011.2016b500, na.rm = TRUE),
    sd = sd(Bike_lane_diff.by.street.2011.2016b500, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(Bike_lane_diff.by.street.2011.2016b500 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1    951   951.2   45.84 2.76e-11 ***
## Residuals            686  14235    20.8                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(Bike_lane_diff.by.street.2011.2016b500 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b500 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -8.615 -2.649 -1.577  1.713 18.848 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.6491     0.2075  12.766  < 2e-16 ***
## gentrified_2016_2011TRUE   2.5772     0.3779   6.819 2.01e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.556 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.06331,    Adjusted R-squared:  0.06195 
## F-statistic:  46.5 on 1 and 688 DF,  p-value: 2.008e-11
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.986 -2.875 -1.306  1.780 18.060 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   4.15471    0.32753  12.685  < 2e-16 ***
## gentrified_2016_2011TRUE      2.62991    0.36967   7.114 2.84e-12 ***
## Bike_lane.by.street.2011b500 -0.17200    0.02968  -5.794 1.05e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.451 on 685 degrees of freedom
## Multiple R-squared:  0.1064, Adjusted R-squared:  0.1038 
## F-statistic: 40.79 on 2 and 685 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 30.874, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7074182195    -0.0027699887     0.0005291311
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 932.41, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1002.3, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.063054, df = 1, p-value = 0.8017
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 69.998, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1002.4, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ================================================================================
##                                              Dependent variable:                
##                              ---------------------------------------------------
##                                    Bike_lane_diff.by.street.2011.2016b500       
##                                        OLS              spatial       spatial   
##                                                      autoregressive    error    
##                                        (1)                (2)           (3)     
## --------------------------------------------------------------------------------
## gentrified_2016_2011                2.630***             0.279*        0.078    
##                                      (0.370)            (0.162)       (0.174)   
##                                                                                 
## Bike_lane.by.street.2011b500        -0.172***          -0.036***     -0.063***  
##                                      (0.030)            (0.013)       (0.023)   
##                                                                                 
## Constant                            4.155***            0.492***      4.099***  
##                                      (0.328)            (0.155)       (1.110)   
##                                                                                 
## --------------------------------------------------------------------------------
## Observations                           688                688           688     
## R2                                    0.106                                     
## Adjusted R2                           0.104                                     
## Log Likelihood                                         -1,527.385    -1,528.615 
## sigma2                                                   3.774         3.755    
## Akaike Inf. Crit.                                      3,064.769     3,067.230  
## Residual Std. Error             4.451 (df = 685)                                
## F Statistic                  40.795*** (df = 2; 685)                            
## Wald Test (df = 1)                                    5,352.089***  6,032.058***
## LR Test (df = 1)                                       949.165***    946.705*** 
## ================================================================================
## Note:                                                *p<0.1; **p<0.05; ***p<0.01
5.1.3.1.4 Buffers 750m
f <- Bike_lane_diff.by.street.2011.2016b750 ~ gentrified_2016_2011 + Bike_lane.by.street.2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=Bike_lane_diff.by.street.2011.2016b750, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(Bike_lane_diff.by.street.2011.2016b750, na.rm = TRUE),
    sd = sd(Bike_lane_diff.by.street.2011.2016b750, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(Bike_lane_diff.by.street.2011.2016b750 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1    749   748.8   44.52 5.19e-11 ***
## Residuals            686  11538    16.8                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(Bike_lane_diff.by.street.2011.2016b750 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016b750 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.893 -2.732 -1.275  1.702 17.528 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.7319     0.1867  14.630  < 2e-16 ***
## gentrified_2016_2011TRUE   2.2850     0.3401   6.719 3.85e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.1 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.06157,    Adjusted R-squared:  0.06021 
## F-statistic: 45.14 on 1 and 688 DF,  p-value: 3.848e-11
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.1403 -2.7267 -0.9595  1.7641 16.6985 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   4.26057    0.31606  13.480  < 2e-16 ***
## gentrified_2016_2011TRUE      2.36887    0.33283   7.117 2.78e-12 ***
## Bike_lane.by.street.2011b750 -0.17498    0.02978  -5.877 6.54e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.004 on 685 degrees of freedom
## Multiple R-squared:  0.106,  Adjusted R-squared:  0.1034 
## F-statistic: 40.62 on 2 and 685 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 33.39, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7650824024    -0.0028690049     0.0005289667
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1090.6, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1168, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.082315, df = 1, p-value = 0.7742
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 77.457, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1168.1, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =================================================================================
##                                              Dependent variable:                 
##                              ----------------------------------------------------
##                                     Bike_lane_diff.by.street.2011.2016b750       
##                                        OLS              spatial        spatial   
##                                                      autoregressive     error    
##                                        (1)                (2)            (3)     
## ---------------------------------------------------------------------------------
## gentrified_2016_2011                2.369***             0.083         -0.076    
##                                      (0.333)            (0.120)        (0.129)   
##                                                                                  
## Bike_lane.by.street.2011b750        -0.175***           -0.025**      -0.048**   
##                                      (0.030)            (0.011)        (0.022)   
##                                                                                  
## Constant                            4.261***            0.361***      3.794***   
##                                      (0.316)            (0.123)        (1.193)   
##                                                                                  
## ---------------------------------------------------------------------------------
## Observations                           688                688            688     
## R2                                    0.106                                      
## Adjusted R2                           0.103                                      
## Log Likelihood                                         -1,331.952    -1,332.336  
## sigma2                                                   2.070          2.060    
## Akaike Inf. Crit.                                      2,673.905      2,674.673  
## Residual Std. Error             4.004 (df = 685)                                 
## F Statistic                  40.615*** (df = 2; 685)                             
## Wald Test (df = 1)                                    9,880.940***  10,824.700***
## LR Test (df = 1)                                      1,194.630***  1,193.862*** 
## =================================================================================
## Note:                                                 *p<0.1; **p<0.05; ***p<0.01

5.1.3.2 Canopy change

Measuring canopy (i.e. greenness ~ grass & trees) ratio within CT/buffer in 2011 (in %)

5.1.3.2.1 Census tract level
f <- pct_esp_vert_diff_2011.2017ct ~ gentrified_2016_2011 + pct_esp_vert_2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017ct, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_2011.2017ct, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_2011.2017ct, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_2011.2017ct ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value  Pr(>F)   
## gentrified_2016_2011   1     93   92.99   8.031 0.00473 **
## Residuals            686   7943   11.58                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_2011.2017ct ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017ct ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.644  -1.868  -0.258   1.425  37.232 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                3.9077     0.1551   25.20  < 2e-16 ***
## gentrified_2016_2011TRUE   0.8164     0.2825    2.89  0.00397 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.405 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.012,  Adjusted R-squared:  0.01056 
## F-statistic: 8.355 on 1 and 688 DF,  p-value: 0.003968
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.458  -1.707  -0.313   1.371  37.172 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               5.51636    0.38260  14.418  < 2e-16 ***
## gentrified_2016_2011TRUE  0.31340    0.29844   1.050    0.294    
## pct_esp_vert_2011ct      -0.03880    0.00854  -4.543 6.56e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.355 on 685 degrees of freedom
## Multiple R-squared:  0.04048,    Adjusted R-squared:  0.03768 
## F-statistic: 14.45 on 2 and 685 DF,  p-value: 7.14e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 14.716, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.3357650342    -0.0026763778     0.0005288861
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 210.05, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 220.39, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.82358, df = 1, p-value = 0.3641
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 11.162, df = 1, p-value = 0.000835
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 221.21, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ======================================================================
##                                     Dependent variable:               
##                      -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017ct          
##                                OLS              spatial      spatial  
##                                              autoregressive   error   
##                                (1)                (2)          (3)    
## ----------------------------------------------------------------------
## gentrified_2016_2011          0.313              0.166        0.094   
##                              (0.298)            (0.257)      (0.269)  
##                                                                       
## pct_esp_vert_2011ct         -0.039***          -0.020***     -0.022** 
##                              (0.009)            (0.007)      (0.010)  
##                                                                       
## Constant                    5.516***            2.509***     4.979*** 
##                              (0.383)            (0.394)      (0.486)  
##                                                                       
## ----------------------------------------------------------------------
## Observations                   688                688          688    
## R2                            0.040                                   
## Adjusted R2                   0.038                                   
## Log Likelihood                                 -1,728.983   -1,731.450
## sigma2                                           8.318        8.369   
## Akaike Inf. Crit.                              3,467.966    3,472.900 
## Residual Std. Error     3.355 (df = 685)                              
## F Statistic          14.449*** (df = 2; 685)                          
## Wald Test (df = 1)                             190.840***   192.246***
## LR Test (df = 1)                               157.094***   152.160***
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01
5.1.3.2.2 Buffer 250m
f <- pct_esp_vert_diff_2011.2017b250 ~ gentrified_2016_2011 + pct_esp_vert_2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b250, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_2011.2017b250, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_2011.2017b250, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_2011.2017b250 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)  
## gentrified_2016_2011   1     54   54.16   6.366 0.0119 *
## Residuals            686   5836    8.51                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_2011.2017b250 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b250 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.651 -1.681 -0.051  1.254 34.949 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                3.7612     0.1329  28.305   <2e-16 ***
## gentrified_2016_2011TRUE   0.6236     0.2420   2.577   0.0102 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.917 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.009557,   Adjusted R-squared:  0.008118 
## F-statistic: 6.639 on 1 and 688 DF,  p-value: 0.01018
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.860 -1.519 -0.207  1.078 35.032 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               5.60208    0.36123  15.508  < 2e-16 ***
## gentrified_2016_2011TRUE  0.13363    0.25303   0.528    0.598    
## pct_esp_vert_2011b250    -0.04733    0.00872  -5.427 7.94e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.858 on 685 degrees of freedom
## Multiple R-squared:  0.05005,    Adjusted R-squared:  0.04727 
## F-statistic: 18.04 on 2 and 685 DF,  p-value: 2.307e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 21.727, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.4968520173    -0.0028203404     0.0005289165
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 459.95, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 470.42, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.00014306, df = 1, p-value = 0.9905
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 10.473, df = 1, p-value = 0.001211
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 470.42, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                      Dependent variable:               
##                       -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017b250         
##                                 OLS              spatial      spatial  
##                                               autoregressive   error   
##                                 (1)                (2)          (3)    
## -----------------------------------------------------------------------
## gentrified_2016_2011           0.134              -0.125       -0.201  
##                               (0.253)            (0.185)      (0.192)  
##                                                                        
## pct_esp_vert_2011b250        -0.047***          -0.019***     -0.026** 
##                               (0.009)            (0.007)      (0.012)  
##                                                                        
## Constant                     5.602***            1.782***     4.897*** 
##                               (0.361)            (0.313)      (0.517)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                    688                688          688    
## R2                             0.050                                   
## Adjusted R2                    0.047                                   
## Log Likelihood                                  -1,528.797   -1,530.330
## sigma2                                            4.377        4.382   
## Akaike Inf. Crit.                               3,067.593    3,070.660 
## Residual Std. Error      2.858 (df = 685)                              
## F Statistic           18.044*** (df = 2; 685)                          
## Wald Test (df = 1)                              562.336***   582.334***
## LR Test (df = 1)                                336.894***   333.827***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
5.1.3.2.3 Buffer 500m
f <- pct_esp_vert_diff_2011.2017b500 ~ gentrified_2016_2011 + pct_esp_vert_2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b500, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df  %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_2011.2017b500, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_2011.2017b500, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_2011.2017b500 ~ gentrified_2016_2011, data = clean_bei$df )
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value  Pr(>F)   
## gentrified_2016_2011   1     57   56.66   7.673 0.00576 **
## Residuals            686   5066    7.38                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_2011.2017b500 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b500 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.458 -1.598 -0.028  1.220 32.312 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                3.6984     0.1238  29.878   <2e-16 ***
## gentrified_2016_2011TRUE   0.6364     0.2255   2.823   0.0049 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.718 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.01145,    Adjusted R-squared:  0.01001 
## F-statistic: 7.967 on 1 and 688 DF,  p-value: 0.004902
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -6.014 -1.431 -0.231  1.041 32.462 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               5.393363   0.352148  15.316  < 2e-16 ***
## gentrified_2016_2011TRUE  0.217268   0.235580   0.922    0.357    
## pct_esp_vert_2011b500    -0.043753   0.008587  -5.095 4.51e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.669 on 685 degrees of freedom
## Multiple R-squared:  0.04717,    Adjusted R-squared:  0.04439 
## F-statistic: 16.96 on 2 and 685 DF,  p-value: 6.493e-08
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 24.745, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5662206004    -0.0028761270     0.0005289293
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 597.35, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 611.05, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.26912, df = 1, p-value = 0.6039
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 13.976, df = 1, p-value = 0.0001851
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 611.32, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =======================================================================
##                                      Dependent variable:               
##                       -------------------------------------------------
##                                pct_esp_vert_diff_2011.2017b500         
##                                 OLS              spatial      spatial  
##                                               autoregressive   error   
##                                 (1)                (2)          (3)    
## -----------------------------------------------------------------------
## gentrified_2016_2011           0.217              -0.096       -0.175  
##                               (0.236)            (0.156)      (0.162)  
##                                                                        
## pct_esp_vert_2011b500        -0.044***           -0.014**      -0.018  
##                               (0.009)            (0.006)      (0.012)  
##                                                                        
## Constant                     5.393***            1.353***     4.535*** 
##                               (0.352)            (0.272)      (0.540)  
##                                                                        
## -----------------------------------------------------------------------
## Observations                    688                688          688    
## R2                             0.047                                   
## Adjusted R2                    0.044                                   
## Log Likelihood                                  -1,424.651   -1,426.239
## sigma2                                            3.127        3.130   
## Akaike Inf. Crit.                               2,859.302    2,862.479 
## Residual Std. Error      2.669 (df = 685)                              
## F Statistic           16.956*** (df = 2; 685)                          
## Wald Test (df = 1)                              935.341***   974.711***
## LR Test (df = 1)                                451.124***   447.947***
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
5.1.3.2.4 Buffer 750m
f <- pct_esp_vert_diff_2011.2017b750 ~ gentrified_2016_2011 + pct_esp_vert_2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_2011.2017b750, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_2011.2017b750, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_2011.2017b750, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_2011.2017b750 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value  Pr(>F)   
## gentrified_2016_2011   1     51   51.28   7.511 0.00629 **
## Residuals            686   4684    6.83                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_2011.2017b750 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_2011.2017b750 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.8790 -1.5176 -0.0082  1.1328 29.4368 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                3.6532     0.1190  30.690  < 2e-16 ***
## gentrified_2016_2011TRUE   0.6058     0.2168   2.794  0.00535 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.613 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.01122,    Adjusted R-squared:  0.009784 
## F-statistic: 7.808 on 1 and 688 DF,  p-value: 0.005348
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.5516 -1.3652 -0.1801  1.0704 29.6156 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               5.234704   0.347343  15.071  < 2e-16 ***
## gentrified_2016_2011TRUE  0.239837   0.225912   1.062    0.289    
## pct_esp_vert_2011b750    -0.040928   0.008521  -4.803 1.92e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.572 on 685 degrees of freedom
## Multiple R-squared:  0.04306,    Adjusted R-squared:  0.04026 
## F-statistic: 15.41 on 2 and 685 DF,  p-value: 2.84e-07
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 27.92, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.6391860882    -0.0029239083     0.0005288989
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 761.22, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 774.97, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.34415, df = 1, p-value = 0.5574
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 14.09, df = 1, p-value = 0.0001743
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 775.31, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## =========================================================================
##                                       Dependent variable:                
##                       ---------------------------------------------------
##                                 pct_esp_vert_diff_2011.2017b750          
##                                 OLS              spatial       spatial   
##                                               autoregressive    error    
##                                 (1)                (2)           (3)     
## -------------------------------------------------------------------------
## gentrified_2016_2011           0.240              -0.064        -0.123   
##                               (0.226)            (0.133)       (0.138)   
##                                                                          
## pct_esp_vert_2011b750        -0.041***           -0.010**       -0.013   
##                               (0.009)            (0.005)       (0.012)   
##                                                                          
## Constant                     5.235***            0.997***      4.280***  
##                               (0.347)            (0.234)       (0.564)   
##                                                                          
## -------------------------------------------------------------------------
## Observations                    688                688           688     
## R2                             0.043                                     
## Adjusted R2                    0.040                                     
## Log Likelihood                                  -1,329.570    -1,330.743 
## sigma2                                            2.295         2.295    
## Akaike Inf. Crit.                               2,669.139     2,671.487  
## Residual Std. Error      2.572 (df = 685)                                
## F Statistic           15.411*** (df = 2; 685)                            
## Wald Test (df = 1)                             1,519.604***  1,582.069***
## LR Test (df = 1)                                590.185***    587.838*** 
## =========================================================================
## Note:                                         *p<0.1; **p<0.05; ***p<0.01

5.1.3.3 Canopy (trees) change

Measuring high canopy (i.e. trees only) ratio within CT/buffer in 2011 (in %)

5.1.3.3.1 Census tract level
f <- pct_esp_vert_diff_high_2011.2017ct ~ gentrified_2016_2011 + pct_esp_vert_high_2011ct

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017ct, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_high_2011.2017ct, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_high_2011.2017ct, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_high_2011.2017ct ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1    108  108.31   22.07 3.18e-06 ***
## Residuals            686   3367    4.91                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_high_2011.2017ct ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017ct ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.6852 -1.4752 -0.3852  1.1357 10.1048 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                3.1052     0.1015  30.600  < 2e-16 ***
## gentrified_2016_2011TRUE   0.8555     0.1848   4.628  4.4e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.228 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0302, Adjusted R-squared:  0.02879 
## F-statistic: 21.42 on 1 and 688 DF,  p-value: 4.404e-06
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.6005 -1.4146 -0.3332  1.0485  9.9254 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              2.113308   0.195404  10.815  < 2e-16 ***
## gentrified_2016_2011TRUE 1.041557   0.182198   5.717 1.62e-08 ***
## pct_esp_vert_high_2011ct 0.051083   0.008758   5.833 8.40e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.164 on 685 degrees of freedom
## Multiple R-squared:  0.07701,    Adjusted R-squared:  0.07431 
## F-statistic: 28.58 on 2 and 685 DF,  p-value: 1.203e-12
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 22.694, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.5197098492    -0.0024634882     0.0005294459
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 503.24, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 535.73, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.017721, df = 1, p-value = 0.8941
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 32.508, df = 1, p-value = 1.187e-08
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 535.75, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==========================================================================
##                                         Dependent variable:               
##                          -------------------------------------------------
##                                 pct_esp_vert_diff_high_2011.2017ct        
##                                    OLS              spatial      spatial  
##                                                  autoregressive   error   
##                                    (1)                (2)          (3)    
## --------------------------------------------------------------------------
## gentrified_2016_2011            1.042***            0.423***      0.210   
##                                  (0.182)            (0.129)      (0.140)  
##                                                                           
## pct_esp_vert_high_2011ct        0.051***            0.034***     0.044*** 
##                                  (0.009)            (0.006)      (0.008)  
##                                                                           
## Constant                        2.113***             0.203       2.759*** 
##                                  (0.195)            (0.159)      (0.284)  
##                                                                           
## --------------------------------------------------------------------------
## Observations                       688                688          688    
## R2                                0.077                                   
## Adjusted R2                       0.074                                   
## Log Likelihood                                     -1,314.367   -1,316.308
## sigma2                                               2.332        2.328   
## Akaike Inf. Crit.                                  2,638.733    2,642.615 
## Residual Std. Error         2.164 (df = 685)                              
## F Statistic              28.576*** (df = 2; 685)                          
## Wald Test (df = 1)                                 648.117***   683.817***
## LR Test (df = 1)                                   382.914***   379.032***
## ==========================================================================
## Note:                                          *p<0.1; **p<0.05; ***p<0.01
5.1.3.3.2 Buffer 250m
f <- pct_esp_vert_diff_high_2011.2017b250 ~ gentrified_2016_2011 + pct_esp_vert_high_2011b250

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b250, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_high_2011.2017b250, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_high_2011.2017b250, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_high_2011.2017b250 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1   79.5   79.52   24.31 1.03e-06 ***
## Residuals            686 2243.8    3.27                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_high_2011.2017b250 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b250 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.8444 -1.2019 -0.3344  0.7941  6.9256 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.8744     0.0824  34.885  < 2e-16 ***
## gentrified_2016_2011TRUE   0.7360     0.1501   4.904 1.17e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.809 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.03378,    Adjusted R-squared:  0.03237 
## F-statistic: 24.05 on 1 and 688 DF,  p-value: 1.173e-06
# Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.9907 -1.1369 -0.3042  0.7484  6.7277 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 1.87785    0.17643  10.644  < 2e-16 ***
## gentrified_2016_2011TRUE    0.86791    0.14744   5.887 6.17e-09 ***
## pct_esp_vert_high_2011b250  0.05546    0.00878   6.317 4.81e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.759 on 685 degrees of freedom
## Multiple R-squared:  0.08738,    Adjusted R-squared:  0.08472 
## F-statistic: 32.79 on 2 and 685 DF,  p-value: 2.505e-14
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 31.923, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7317729272    -0.0026690819     0.0005292956
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 997.72, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1056.8, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.15586, df = 1, p-value = 0.693
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 59.218, df = 1, p-value = 1.41e-14
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1056.9, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==============================================================================
##                                            Dependent variable:                
##                            ---------------------------------------------------
##                                   pct_esp_vert_diff_high_2011.2017b250        
##                                      OLS              spatial       spatial   
##                                                    autoregressive    error    
##                                      (1)                (2)           (3)     
## ------------------------------------------------------------------------------
## gentrified_2016_2011              0.868***             0.098         0.008    
##                                    (0.147)            (0.067)       (0.072)   
##                                                                               
## pct_esp_vert_high_2011b250        0.055***            0.020***      0.031***  
##                                    (0.009)            (0.004)       (0.006)   
##                                                                               
## Constant                          1.878***             -0.045       2.905***  
##                                    (0.176)            (0.086)       (0.354)   
##                                                                               
## ------------------------------------------------------------------------------
## Observations                         688                688           688     
## R2                                  0.087                                     
## Adjusted R2                         0.085                                     
## Log Likelihood                                        -904.608      -905.553  
## sigma2                                                 0.633         0.629    
## Akaike Inf. Crit.                                    1,819.217     1,821.107  
## Residual Std. Error           1.759 (df = 685)                                
## F Statistic                32.795*** (df = 2; 685)                            
## Wald Test (df = 1)                                  3,670.366***  3,898.463***
## LR Test (df = 1)                                     917.605***    915.715*** 
## ==============================================================================
## Note:                                              *p<0.1; **p<0.05; ***p<0.01
5.1.3.3.3 Buffer 500m
f <- pct_esp_vert_diff_high_2011.2017b500 ~ gentrified_2016_2011 + pct_esp_vert_high_2011b500

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b500, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_high_2011.2017b500, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_high_2011.2017b500, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_high_2011.2017b500 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1   72.1   72.14    25.5 5.67e-07 ***
## Residuals            686 1940.5    2.83                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_high_2011.2017b500 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b500 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7769 -1.1369 -0.3169  0.7417  7.8431 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               2.80691    0.07665  36.618  < 2e-16 ***
## gentrified_2016_2011TRUE  0.69848    0.13961   5.003 7.18e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.683 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:  0.0351, Adjusted R-squared:  0.0337 
## F-statistic: 25.03 on 1 and 688 DF,  p-value: 7.176e-07
#  Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.2362 -1.0221 -0.2485  0.6756  7.6656 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                1.802357   0.172956  10.421  < 2e-16 ***
## gentrified_2016_2011TRUE   0.819289   0.136895   5.985 3.49e-09 ***
## pct_esp_vert_high_2011b500 0.055679   0.008705   6.396 2.95e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.635 on 685 degrees of freedom
## Multiple R-squared:  0.09018,    Adjusted R-squared:  0.08752 
## F-statistic: 33.95 on 2 and 685 DF,  p-value: 8.755e-15
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 34.479, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.7903911948    -0.0027761623     0.0005291877
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1164, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1235.7, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.010423, df = 1, p-value = 0.9187
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 71.771, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1235.7, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ==============================================================================
##                                            Dependent variable:                
##                            ---------------------------------------------------
##                                   pct_esp_vert_diff_high_2011.2017b500        
##                                      OLS              spatial       spatial   
##                                                    autoregressive    error    
##                                      (1)                (2)           (3)     
## ------------------------------------------------------------------------------
## gentrified_2016_2011              0.819***             0.015         -0.035   
##                                    (0.137)            (0.048)       (0.052)   
##                                                                               
## pct_esp_vert_high_2011b500        0.056***            0.014***      0.025***  
##                                    (0.009)            (0.003)       (0.006)   
##                                                                               
## Constant                          1.802***             -0.056       2.943***  
##                                    (0.173)            (0.064)       (0.434)   
##                                                                               
## ------------------------------------------------------------------------------
## Observations                         688                688           688     
## R2                                  0.090                                     
## Adjusted R2                         0.088                                     
## Log Likelihood                                        -700.169      -700.342  
## sigma2                                                 0.332         0.331    
## Akaike Inf. Crit.                                    1,410.337     1,410.684  
## Residual Std. Error           1.635 (df = 685)                                
## F Statistic                33.948*** (df = 2; 685)                            
## Wald Test (df = 1)                                  8,846.070***  9,245.586***
## LR Test (df = 1)                                    1,225.619***  1,225.272***
## ==============================================================================
## Note:                                              *p<0.1; **p<0.05; ***p<0.01
5.1.3.3.4 Buffer 750m
f <- pct_esp_vert_diff_high_2011.2017b750 ~ gentrified_2016_2011 + pct_esp_vert_high_2011b750

clean_bei <- tidy_df(bei_df_aoi, CT16, f)

ggplot(clean_bei$df, aes(y=pct_esp_vert_diff_high_2011.2017b750, x=gentrified_2016_2011)) +
  geom_boxplot()

clean_bei$df %>%
  group_by(gentrified_2016_2011) %>%
  summarise(
    count = n(),
    mean = mean(pct_esp_vert_diff_high_2011.2017b750, na.rm = TRUE),
    sd = sd(pct_esp_vert_diff_high_2011.2017b750, na.rm = TRUE)
  )
# Compute the analysis of variance
res.aov <- aov(pct_esp_vert_diff_high_2011.2017b750 ~ gentrified_2016_2011, data = clean_bei$df)
# Summary of the analysis
summary(res.aov)
##                       Df Sum Sq Mean Sq F value   Pr(>F)    
## gentrified_2016_2011   1   69.5   69.47   28.94 1.02e-07 ***
## Residuals            686 1646.7    2.40                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear model
res.lm <- lm(pct_esp_vert_diff_high_2011.2017b750 ~ gentrified_2016_2011, data = units::drop_units(bei_df_aoi))
summary(res.lm)
## 
## Call:
## lm(formula = pct_esp_vert_diff_high_2011.2017b750 ~ gentrified_2016_2011, 
##     data = units::drop_units(bei_df_aoi))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7009 -1.0767 -0.2509  0.6966  6.7491 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               2.74089    0.07053  38.859  < 2e-16 ***
## gentrified_2016_2011TRUE  0.68781    0.12847   5.354 1.17e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.549 on 688 degrees of freedom
##   (15 observations deleted due to missingness)
## Multiple R-squared:   0.04,  Adjusted R-squared:  0.0386 
## F-statistic: 28.67 on 1 and 688 DF,  p-value: 1.174e-07
#  Accounting for UC in 2011
res.lm <- lm(f, data = clean_bei$df)
summary(res.lm)
## 
## Call:
## lm(formula = f, data = clean_bei$df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1510 -0.9533 -0.2518  0.6475  6.5894 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                1.713891   0.165030  10.385  < 2e-16 ***
## gentrified_2016_2011TRUE   0.793010   0.125439   6.322 4.66e-10 ***
## pct_esp_vert_high_2011b750 0.057247   0.008403   6.813 2.10e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.5 on 685 degrees of freedom
## Multiple R-squared:  0.1014, Adjusted R-squared:  0.09874 
## F-statistic: 38.63 on 2 and 685 DF,  p-value: < 2.2e-16
# Check spatial autocorrelation of residuals
lm.morantest(res.lm, clean_bei$nbw)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## Moran I statistic standard deviate = 35.852, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     0.8217997422    -0.0028477429     0.0005290729
# Test which spatial model?
lm.LMtests(res.lm, clean_bei$nbw, test="all")
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMerr = 1258.3, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## LMlag = 1332.2, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMerr = 0.36272, df = 1, p-value = 0.547
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## RLMlag = 74.286, df = 1, p-value < 2.2e-16
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = f, data = clean_bei$df)
## weights: clean_bei$nbw
## 
## SARMA = 1332.6, df = 2, p-value < 2.2e-16
# Get SAR and SEM models
fit.lag <- lagsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)
fit.err <- errorsarlm(formula = f, data = clean_bei$df, listw = clean_bei$nbw)

stargazer(res.lm, fit.lag, fit.err, type="text")
## 
## ===============================================================================
##                                            Dependent variable:                 
##                            ----------------------------------------------------
##                                    pct_esp_vert_diff_high_2011.2017b750        
##                                      OLS              spatial        spatial   
##                                                    autoregressive     error    
##                                      (1)                (2)            (3)     
## -------------------------------------------------------------------------------
## gentrified_2016_2011              0.793***             0.033          0.020    
##                                    (0.125)            (0.038)        (0.041)   
##                                                                                
## pct_esp_vert_high_2011b750        0.057***            0.012***      0.027***   
##                                    (0.008)            (0.003)        (0.005)   
##                                                                                
## Constant                          1.714***             -0.079       2.699***   
##                                    (0.165)            (0.052)        (0.456)   
##                                                                                
## -------------------------------------------------------------------------------
## Observations                         688                688            688     
## R2                                  0.101                                      
## Adjusted R2                         0.099                                      
## Log Likelihood                                        -545.987      -543.936   
## sigma2                                                 0.208          0.205    
## Akaike Inf. Crit.                                    1,101.974      1,097.872  
## Residual Std. Error           1.500 (df = 685)                                 
## F Statistic                38.635*** (df = 2; 685)                             
## Wald Test (df = 1)                                 13,200.530***  14,669.400***
## LR Test (df = 1)                                    1,415.843***  1,419.945*** 
## ===============================================================================
## Note:                                               *p<0.1; **p<0.05; ***p<0.01

6 Summary of association between SES and Built Environment

Below we summarize the trends linking SES and BE (looking at association at the 500m buffer scale and INTERACT study area). NB Based on regular regression models. Yet, Moran’s I metric confirms that spatial autocorrelation exists and needs to be taken care of. We run spatial autoregressive and spatial error models (package spatialreg). Neighborhood is based on queen contiguity. Direction of association is maintained although strength is generally much lower and association significance may be lost.

SES metric BE metric UC 2011 trend UI 2011 -> 2016 trend
Pampalon / MAT 2011 Bike lane -***† x (-**‡ when controlling for UC)
Pampalon / MAT 2011 Greenness -***‡ x (-*† when controlling for UC)
Pampalon / MAT 2011 Tree canopy -***† -***†
Visible Minority 2011 Bike lane -***† -***†
Visible Minority 2011 Greenness -***‡ -* (-**† when controlling for UC)
Visible Minority 2011 Tree canopy -***‡ -***†
Gentrified 2011-2016 Bike lane x +***†
Gentrified 2011-2016 Greenness -***† +** (x† when controlling for UC)
Gentrified 2011-2016 Tree canopy -***† +***†

x: no significant association
-: negative association (higher SES metric => lower BE metric)
+: positive association (higher SES metric => higher BE metric)

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Spatial models: '†' SAR '‡' SEM ' ' OLS

Controlling for UC in UI models does not change the association trend; even better, non significant association may become (slightly) significant.

7 Exploratory stuff

7.1 Urban conditions and SES

Tackling part 2 of objective #1: a multilevel model to test the reduction in socio-economic inequalities in urban conditions \[𝔼(UC_{ij} \mid X_{ij}) = \beta_{0j} + \beta_{1j} ∗ SES + \beta_{2j} ∗ Time + \beta_{3j} ∗ SES ∗ Time + \epsilon_{ij}\]

Data for bike lanes is available for 2006, 2011 and 2016 whereas greenness (and trees) is only available for 2011 and 2016.

# Get SCOREMAT
.bei_df_mlm.1 <- bei_df %>%
  select(CT_UID, starts_with("wSCOREMAT")) %>%
  pivot_longer(cols = starts_with("wSCOREMAT"), 
               names_to = "Year", names_prefix = "wSCOREMAT.", 
               values_to = "wSCOREMAT", values_drop_na = TRUE)
# Get vis_minority
.bei_df_mlm.2 <- bei_df %>%
  select(CT_UID, starts_with("vis_minority")) %>%
  pivot_longer(cols = starts_with("vis_minority"), 
               names_to = "Year", names_prefix = "vis_minority_", 
               values_to = "vis_minority", values_drop_na = TRUE)
# Get gentrified flag
.bei_df_mlm.3 <- bei_df %>%
  select(CT_UID, starts_with("gentrified_")) %>%
  pivot_longer(cols = starts_with("gentrified_"), 
               names_to = "Year_span", names_prefix = "gentrified_", 
               values_to = "gentrified", values_drop_na = TRUE) %>%
  extract(Year_span, "Year", "(\\d{4})_*")
# Get bike_lane
.bei_df_mlm.4 <- bei_df %>%
  select(CT_UID, starts_with("Bike_lane.by.street")) %>%
  pivot_longer(cols = starts_with("Bike_lane.by.street"), 
               names_to = "Var", names_prefix = "Bike_lane.by.street.",
               values_to = "bike_lane.by.street", values_drop_na = TRUE) %>%
  extract("Var", c("Year", "Spatial.scale"), "(\\d{4})([[:alnum:]]+)")
# Get Canopy
.bei_df_mlm.5 <- bei_df %>%
  select(CT_UID, starts_with("pct_esp_vert_20")) %>%
  pivot_longer(cols = starts_with("pct_esp_vert_"), 
               names_to = "Var", names_prefix = "pct_esp_vert_",
               values_to = "pct_esp_vert", values_drop_na = TRUE) %>%
  extract("Var", c("Year", "Spatial.scale"), "(\\d{4})([[:alnum:]]+)") %>%
  filter(Year %in% c('2011', '2017')) %>%
  mutate(Year = case_when(Year == '2017' ~ '2016',
                          TRUE ~ Year))
# Get Canopy
.bei_df_mlm.6 <- bei_df %>%
  select(CT_UID, starts_with("pct_esp_vert_high_20")) %>%
  pivot_longer(cols = starts_with("pct_esp_vert_high"), 
               names_to = "Var", names_prefix = "pct_esp_vert_high_",
               values_to = "pct_esp_vert_high", values_drop_na = TRUE) %>%
  extract("Var", c("Year", "Spatial.scale"), "(\\d{4})([[:alnum:]]+)") %>%
  filter(Year %in% c('2011', '2017')) %>%
  mutate(Year = case_when(Year == '2017' ~ '2016',
                          TRUE ~ Year))

# Combine all subsets
bei_df_mlm <- bei_df %>%
  select(CT_UID, interact_aoi, Population) %>%
  full_join(.bei_df_mlm.1, by=c("CT_UID")) %>%
  full_join(.bei_df_mlm.2, by=c("CT_UID", "Year")) %>%
  full_join(.bei_df_mlm.3, by=c("CT_UID", "Year")) %>%
  full_join(.bei_df_mlm.4, by=c("CT_UID", "Year")) %>%
  full_join(.bei_df_mlm.5, by=c("CT_UID", "Year", "Spatial.scale")) %>%
  full_join(.bei_df_mlm.6, by=c("CT_UID", "Year", "Spatial.scale")) %>%
  units::drop_units() %>%
  #mutate(Year = factor(Year, levels = c("2006", "2011", "2016")))
  mutate(Yr = factor(Year, levels = c("2006", "2011", "2016")),
         Year = as.numeric(Year))
# Build adjacency matrix to feed spaMM models
ct_nb <- poly2nb(CT16, row.names = "GeoUID")
mtx_nb <- nb2mat(ct_nb, style = "B", zero.policy = TRUE)

ct_mtx_lut <- CT16 %>%
  as.data.frame() %>%
  transmute(CT_UID = GeoUID,
            CT_Code = row_number())

7.1.1 Model 1: SCOREMAT & bike lanes

Here, SES is measured through Pampalon Material Score and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area. Using 2006 as reference year.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  mutate(delta.Year = Year - 2006)

#res.mlm.1 <- lmer(bike_lane.by.street ~ wSCOREMAT*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
res.mlm.1 <- lmer(bike_lane.by.street ~ wSCOREMAT*Yr + (1 | CT_UID), data = mlm_data, REML = FALSE)
summary(res.mlm.1)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bike_lane.by.street ~ wSCOREMAT * Yr + (1 | CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##  12080.9  12126.0  -6032.4  12064.9     2064 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6910 -0.5689  0.0150  0.4956  3.9721 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 21.74    4.663   
##  Residual             10.12    3.182   
## Number of obs: 2072, groups:  CT_UID, 693
## 
## Fixed effects:
##                  Estimate Std. Error t value
## (Intercept)        6.1993     0.2146  28.888
## wSCOREMAT        -30.0030     5.0477  -5.944
## Yr2011             2.7976     0.1731  16.166
## Yr2016             6.0636     0.1713  35.393
## wSCOREMAT:Yr2011  -6.6511     4.4273  -1.502
## wSCOREMAT:Yr2016 -19.2234     4.4824  -4.289
## 
## Correlation of Fixed Effects:
##                 (Intr) wSCOREMAT Yr2011 Yr2016 wSCOREMAT:Y2011
## wSCOREMAT       -0.001                                        
## Yr2011          -0.395 -0.079                                 
## Yr2016          -0.399 -0.002     0.496                       
## wSCOREMAT:Y2011  0.002 -0.502    -0.061 -0.004                
## wSCOREMAT:Y2016  0.003 -0.490    -0.001 -0.007  0.537
# Plot interactions
plot_model(res.mlm.1, type = 'int')

#emmip(res.mlm.1, delta.Year~wSCOREMAT, at = list(delta.Year = c(0, 5, 10), wSCOREMAT=seq(-.2, .2, by=.01)), CI=TRUE)
# Define multilevel model | buf 500m / INTERACT study area / Spatial auto-regressive
spm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  inner_join(ct_mtx_lut, by="CT_UID") %>%
  mutate(delta.Year = Year - 2006)

#res.spm.1 <- fitme(bike_lane.by.street ~ wSCOREMAT*delta.Year + adjacency(1 | CT_Code), 
res.spm.1 <- fitme(bike_lane.by.street ~ wSCOREMAT*Yr + adjacency(1 | CT_Code), 
                   data = spm_data, adjMatrix = mtx_nb)
## Warning in .sym_checked(adjMatrix, "adjMatrix"): Forcing colnames(mMatrix) <-
## rownames(mMatrix) before calling isSymmetric().
## If the 'RSpectra' package were installed, an extreme eigenvalue computation could be faster.
summary(res.spm.1)
## formula: bike_lane.by.street ~ wSCOREMAT * Yr + adjacency(1 | CT_Code)
## ML: Estimation of corrPars, lambda and phi by ML.
##     Estimation of fixed effects by ML.
## Estimation of lambda and phi by 'outer' ML, maximizing p_v.
## family: gaussian( link = identity ) 
##  ------------ Fixed effects (beta) ------------
##                  Estimate Cond. SE t-value
## (Intercept)         7.655   0.3369  22.722
## wSCOREMAT         -26.002   5.0853  -5.113
## Yr2011              2.775   0.1710  16.225
## Yr2016              6.059   0.1692  35.801
## wSCOREMAT:Yr2011   -6.299   4.3694  -1.442
## wSCOREMAT:Yr2016  -18.620   4.4249  -4.208
##  --------------- Random effects ---------------
## Family: gaussian( link = identity ) 
##                    --- Correlation parameters:
##     1.rho 
## 0.1359364 
##            --- Variance parameters ('lambda'):
## lambda = var(u) for u ~ Gaussian; 
##    CT_Code  :  11.52  
## # of obs: 2072; # of groups: CT_Code, 970 
##  -------------- Residual variance  ------------
## phi estimate was 9.88293 
##  ------------- Likelihood values  -------------
##                        logLik
## p_v(h) (marginal L): -5867.79
# Define multilevel model | buf 500m / INTERACT study area / Integrated Nested Laplace Approx
inla_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  inner_join(ct_mtx_lut, by="CT_UID") %>%
  mutate(delta.Year = Year - 2006)

res.inla.iid.1 <- inla(bike_lane.by.street ~ wSCOREMAT*Yr + f(CT_Code, model="iid"), 
                   data = inla_data,
                   control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(res.inla.iid.1)
## 
## Call:
##    c("inla(formula = bike_lane.by.street ~ wSCOREMAT * Yr + f(CT_Code, ", 
##    " model = \"iid\"), data = inla_data, control.compute = list(dic = 
##    TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 2.28, Running = 1.76, Post = 0.0329, Total = 4.08 
## Fixed effects:
##                     mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)        6.199 0.215      5.778    6.199      6.621   6.199   0
## wSCOREMAT        -29.522 4.978    -39.302  -29.520    -19.760 -29.516   0
## Yr2011             2.795 0.173      2.454    2.795      3.135   2.795   0
## Yr2016             6.063 0.172      5.726    6.063      6.400   6.063   0
## wSCOREMAT:Yr2011  -6.652 4.367    -15.228   -6.651      1.915  -6.650   0
## wSCOREMAT:Yr2016 -19.102 4.421    -27.786  -19.102    -10.429 -19.100   0
## 
## Random effects:
##   Name     Model
##     CT_Code IID model
## 
## Model hyperparameters:
##                                          mean    sd 0.025quant 0.5quant
## Precision for the Gaussian observations 0.099 0.004      0.091    0.099
## Precision for CT_Code                   0.046 0.003      0.041    0.046
##                                         0.975quant  mode
## Precision for the Gaussian observations      0.106 0.098
## Precision for CT_Code                        0.052 0.046
## 
## Deviance Information Criterion (DIC) ...............: 11290.18
## Deviance Information Criterion (DIC, saturated) ....: 48915.67
## Effective number of parameters .....................: 605.27
## 
## Watanabe-Akaike information criterion (WAIC) ...: 11314.83
## Effective number of parameters .................: 518.35
## 
## Marginal log-Likelihood:  -6079.98 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
res.inla.bym.1 <- inla(bike_lane.by.street ~ wSCOREMAT*Yr + f(CT_Code, model="bym", graph=mtx_nb), 
                   data = inla_data,
                   control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(res.inla.bym.1)
## 
## Call:
##    c("inla(formula = bike_lane.by.street ~ wSCOREMAT * Yr + f(CT_Code, ", 
##    " model = \"bym\", graph = mtx_nb), data = inla_data, control.compute = 
##    list(dic = TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 2.22, Running = 1.95, Post = 0.0374, Total = 4.21 
## Fixed effects:
##                     mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)        6.413 0.242      5.936    6.413      6.888   6.413   0
## wSCOREMAT        -32.888 5.059    -42.829  -32.886    -22.969 -32.881   0
## Yr2011             2.807 0.173      2.466    2.807      3.147   2.807   0
## Yr2016             6.064 0.172      5.727    6.064      6.400   6.064   0
## wSCOREMAT:Yr2011  -5.840 4.361    -14.403   -5.840      2.716  -5.840   0
## wSCOREMAT:Yr2016 -18.006 4.416    -26.678  -18.006     -9.343 -18.006   0
## 
## Random effects:
##   Name     Model
##     CT_Code BYM model
## 
## Model hyperparameters:
##                                            mean    sd 0.025quant 0.5quant
## Precision for the Gaussian observations   0.099 0.004      0.091    0.099
## Precision for CT_Code (iid component)     0.335 0.077      0.219    0.323
## Precision for CT_Code (spatial component) 0.026 0.002      0.022    0.026
##                                           0.975quant  mode
## Precision for the Gaussian observations        0.106 0.098
## Precision for CT_Code (iid component)          0.518 0.299
## Precision for CT_Code (spatial component)      0.031 0.026
## 
## Deviance Information Criterion (DIC) ...............: 11217.77
## Deviance Information Criterion (DIC, saturated) ....: 48843.26
## Effective number of parameters .....................: 532.49
## 
## Watanabe-Akaike information criterion (WAIC) ...: 11241.89
## Effective number of parameters .................: 465.35
## 
## Marginal log-Likelihood:  -5754.41 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
res.inla.bym.pois.1 <- inla(as.integer(100*bike_lane.by.street) ~ wSCOREMAT*Yr + f(CT_Code, model="bym", graph=mtx_nb), 
                   data = inla_data, family="poisson",
                   control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(res.inla.bym.pois.1)
## 
## Call:
##    c("inla(formula = as.integer(100 * bike_lane.by.street) ~ wSCOREMAT * 
##    ", " Yr + f(CT_Code, model = \"bym\", graph = mtx_nb), family = 
##    \"poisson\", ", " data = inla_data, control.compute = list(dic = TRUE, 
##    waic = TRUE, ", " cpo = TRUE))") 
## Time used:
##     Pre = 2.25, Running = 15.6, Post = 0.0342, Total = 17.9 
## Fixed effects:
##                    mean    sd 0.025quant 0.5quant 0.975quant   mode kld
## (Intercept)       6.180 0.039      6.104    6.180      6.257  6.181   0
## wSCOREMAT        -3.969 0.090     -4.146   -3.969     -3.792 -3.969   0
## Yr2011            0.367 0.002      0.363    0.367      0.371  0.367   0
## Yr2016            0.680 0.002      0.676    0.680      0.683  0.680   0
## wSCOREMAT:Yr2011  0.149 0.054      0.043    0.149      0.254  0.149   0
## wSCOREMAT:Yr2016  0.266 0.052      0.164    0.266      0.367  0.266   0
## 
## Random effects:
##   Name     Model
##     CT_Code BYM model
## 
## Model hyperparameters:
##                                            mean    sd 0.025quant 0.5quant
## Precision for CT_Code (iid component)     6.698 1.122      4.765    6.603
## Precision for CT_Code (spatial component) 0.399 0.032      0.339    0.398
##                                           0.975quant  mode
## Precision for CT_Code (iid component)          9.171 6.418
## Precision for CT_Code (spatial component)      0.465 0.396
## 
## Deviance Information Criterion (DIC) ...............: 109468.11
## Deviance Information Criterion (DIC, saturated) ....: 131323.56
## Effective number of parameters .....................: -52726.92
## 
## Watanabe-Akaike information criterion (WAIC) ...: 287833.96
## Effective number of parameters .................: 56742.69
## 
## Marginal log-Likelihood:  -110288.81 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')

7.1.2 Model 2: Visibility minority & bike lanes

Here, SES is measured through the % of visible minority population and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  mutate(delta.Year = Year - 2006)

res.mlm.2 <- lmer(bike_lane.by.street ~ vis_minority*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
summary(res.mlm.2)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bike_lane.by.street ~ vis_minority * delta.Year + (1 | CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##  11934.5  11968.3  -5961.2  11922.5     2059 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6629 -0.5617 -0.0067  0.4941  3.7786 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 19.187   4.380   
##  Residual              9.933   3.152   
## Number of obs: 2065, groups:  CT_UID, 691
## 
## Fixed effects:
##                          Estimate Std. Error t value
## (Intercept)              8.270127   0.329009  25.137
## vis_minority            -0.106487   0.012148  -8.766
## delta.Year               0.845371   0.032637  25.902
## vis_minority:delta.Year -0.005666   0.001114  -5.086
## 
## Correlation of Fixed Effects:
##             (Intr) vs_mnr dlt.Yr
## vis_minorty -0.795              
## delta.Year  -0.340  0.245       
## vs_mnrty:.Y  0.437 -0.537 -0.821
# Plot interactions
plot_model(res.mlm.2, type = 'int')

7.1.3 Model 3: SCOREMAT, visible minority & bike lanes

Here, SES is measured through Pampalon Material Score combined with the % of visible minority population and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  mutate(delta.Year = Year - 2006)

res.mlm.3 <- lmer(bike_lane.by.street ~ wSCOREMAT*delta.Year + vis_minority*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(res.mlm.3)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bike_lane.by.street ~ wSCOREMAT * delta.Year + vis_minority *  
##     delta.Year + (1 | CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##  11920.3  11965.4  -5952.1  11904.3     2057 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6895 -0.5686  0.0009  0.4971  3.8313 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 19.285   4.391   
##  Residual              9.792   3.129   
## Number of obs: 2065, groups:  CT_UID, 691
## 
## Fixed effects:
##                           Estimate Std. Error t value
## (Intercept)               7.877530   0.351323  22.422
## wSCOREMAT               -16.282727   5.178330  -3.144
## delta.Year                0.812943   0.036822  22.077
## vis_minority             -0.086567   0.013567  -6.381
## wSCOREMAT:delta.Year     -0.491004   0.518795  -0.946
## delta.Year:vis_minority  -0.005020   0.001297  -3.871
## 
## Correlation of Fixed Effects:
##             (Intr) wSCOREMAT dlt.Yr vs_mnr wSCOREMAT:
## wSCOREMAT    0.355                                   
## delta.Year  -0.324 -0.139                            
## vis_minorty -0.823 -0.449     0.242                  
## wSCOREMAT:. -0.174 -0.499     0.463  0.203           
## dlt.Yr:vs_m  0.438  0.260    -0.858 -0.514 -0.522    
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Plot interactions
plot_model(res.mlm.3, type = 'pred', terms = c('wSCOREMAT', 'vis_minority', 'delta.Year'))

7.1.4 Model 4: SCOREMAT, visible minority & esp_vert

Here, SES is measured through Pampalon Material Score combined to % of visible minority population and urban conditions as the % of greenness within 500m buffers around CT for the INTERACT study area.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  mutate(delta.Year = Year - 2006)

res.mlm.4 <- lmer(pct_esp_vert ~ wSCOREMAT*delta.Year + vis_minority*delta.Year + (1 | CT_UID), data = mlm_data)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(res.mlm.4)
## Linear mixed model fit by REML ['lmerMod']
## Formula: pct_esp_vert ~ wSCOREMAT * delta.Year + vis_minority * delta.Year +  
##     (1 | CT_UID)
##    Data: mlm_data
## 
## REML criterion at convergence: 8727.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -8.1003 -0.3850  0.0039  0.3822  8.3635 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 143.15   11.965  
##  Residual               3.66    1.913  
## Number of obs: 1378, groups:  CT_UID, 691
## 
## Fixed effects:
##                           Estimate Std. Error t value
## (Intercept)              32.779289   0.693038  47.298
## wSCOREMAT               -36.172408   7.773713  -4.653
## delta.Year                0.845882   0.049396  17.125
## vis_minority             -0.031168   0.021497  -1.450
## wSCOREMAT:delta.Year      0.003342   0.626849   0.005
## delta.Year:vis_minority  -0.002711   0.001556  -1.743
## 
## Correlation of Fixed Effects:
##             (Intr) wSCOREMAT dlt.Yr vs_mnr wSCOREMAT:
## wSCOREMAT    0.156                                   
## delta.Year  -0.297 -0.026                            
## vis_minorty -0.707 -0.325     0.187                  
## wSCOREMAT:. -0.162 -0.491     0.477  0.196           
## dlt.Yr:vs_m  0.401  0.232    -0.861 -0.482 -0.552    
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Plot interactions
plot_model(res.mlm.4, type = 'pred', terms = c('wSCOREMAT', 'vis_minority', 'delta.Year'))

7.1.5 Model 5: SCOREMAT, vis_minority & esp_vert_high

Here, SES is measured through Pampalon Material Score combined with % of visible minority population and urban conditions as the % of trees within 500m buffers around CT for the INTERACT study area.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi) %>%
  mutate(delta.Year = Year - 2006)

res.mlm.5 <- lmer(pct_esp_vert_high ~ wSCOREMAT*delta.Year + vis_minority*delta.Year + (1 | CT_UID), data = mlm_data)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(res.mlm.5)
## Linear mixed model fit by REML ['lmerMod']
## Formula: 
## pct_esp_vert_high ~ wSCOREMAT * delta.Year + vis_minority * delta.Year +  
##     (1 | CT_UID)
##    Data: mlm_data
## 
## REML criterion at convergence: 7254.1
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.98339 -0.41949  0.00332  0.40454  3.06727 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 46.920   6.850   
##  Residual              1.302   1.141   
## Number of obs: 1378, groups:  CT_UID, 691
## 
## Fixed effects:
##                           Estimate Std. Error t value
## (Intercept)              1.540e+01  4.042e-01  38.100
## wSCOREMAT               -1.923e+01  4.604e+00  -4.177
## delta.Year               6.103e-01  2.942e-02  20.744
## vis_minority            -3.527e-02  1.269e-02  -2.779
## wSCOREMAT:delta.Year    -2.492e+00  3.738e-01  -6.667
## delta.Year:vis_minority -5.059e-04  9.277e-04  -0.545
## 
## Correlation of Fixed Effects:
##             (Intr) wSCOREMAT dlt.Yr vs_mnr wSCOREMAT:
## wSCOREMAT    0.162                                   
## delta.Year  -0.308 -0.030                            
## vis_minorty -0.716 -0.331     0.195                  
## wSCOREMAT:. -0.167 -0.496     0.477  0.200           
## dlt.Yr:vs_m  0.411  0.235    -0.862 -0.487 -0.551    
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Plot interactions
plot_model(res.mlm.5, type = 'pred', terms = c('wSCOREMAT', 'vis_minority', 'delta.Year'))

7.1.6 Model 6: SCOREMAT & bike lanes, random slope

Here, SES is measured through Pampalon Material Score and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area. Modeled as random slope, not just random intercept.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi)  %>%
  mutate(delta.Year = Year - 2006)

res.mlm.6 <- lmer(bike_lane.by.street ~ wSCOREMAT*delta.Year + (delta.Year | CT_UID), data = mlm_data, REML = FALSE)
summary(res.mlm.6)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bike_lane.by.street ~ wSCOREMAT * delta.Year + (delta.Year |  
##     CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##  11900.1  11945.2  -5942.1  11884.1     2064 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -3.00916 -0.40756  0.00695  0.36142  2.84899 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  CT_UID   (Intercept) 20.2983  4.5054        
##           delta.Year   0.1717  0.4144   -0.08
##  Residual              5.8716  2.4231        
## Number of obs: 2072, groups:  CT_UID, 693
## 
## Fixed effects:
##                       Estimate Std. Error t value
## (Intercept)            6.12408    0.19092  32.076
## wSCOREMAT            -24.50034    4.37362  -5.602
## delta.Year             0.60615    0.02046  29.621
## wSCOREMAT:delta.Year  -2.18277    0.51916  -4.204
## 
## Correlation of Fixed Effects:
##             (Intr) wSCOREMAT dlt.Yr
## wSCOREMAT   -0.029                 
## delta.Year  -0.272 -0.001          
## wSCOREMAT:. -0.004 -0.418    -0.007
# Check if model with random slope significantly improves over random intercept (see http://www.bodowinter.com/tutorial/bw_LME_tutorial1.pdf)
res.mlm.6.null <- lmer(bike_lane.by.street ~ wSCOREMAT*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
anova(res.mlm.6.null, res.mlm.6)

7.1.7 Model 7: SCOREMAT, vis_minority & bike lanes, three-way iteraction

Here, SES is measured through Pampalon Material and % of visible minority and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area. Here, the three-way interaction is modeled, contrary to model 3, where the same variables are considered through two-way interaction (Year & SCOREMAT and Year & vis_minority).

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi)  %>%
  mutate(delta.Year = Year - 2006)

res.mlm.7 <- lmer(bike_lane.by.street ~ wSCOREMAT*vis_minority*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
## Warning: Some predictor variables are on very different scales: consider
## rescaling
summary(res.mlm.7)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bike_lane.by.street ~ wSCOREMAT * vis_minority * delta.Year +  
##     (1 | CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##  11923.4  11979.8  -5951.7  11903.4     2055 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7095 -0.5622  0.0039  0.4893  3.8351 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 19.305   4.394   
##  Residual              9.782   3.128   
## Number of obs: 2065, groups:  CT_UID, 691
## 
## Fixed effects:
##                                     Estimate Std. Error t value
## (Intercept)                         7.921273   0.356795  22.201
## wSCOREMAT                         -20.930417   7.600014  -2.754
## vis_minority                       -0.091188   0.014800  -6.161
## delta.Year                          0.811819   0.037344  21.739
## wSCOREMAT:vis_minority              0.202550   0.241270   0.840
## wSCOREMAT:delta.Year               -0.519784   0.818174  -0.635
## vis_minority:delta.Year            -0.004881   0.001427  -3.421
## wSCOREMAT:vis_minority:delta.Year  -0.003483   0.024586  -0.142
## 
## Correlation of Fixed Effects:
##              (Intr) wSCOREMAT vs_mnr dlt.Yr wSCOREMAT:v_ wSCOREMAT:. vs_:.Y
## wSCOREMAT     0.115                                                        
## vis_minorty  -0.811  0.010                                                 
## delta.Year   -0.337 -0.019     0.264                                       
## wSCOREMAT:v_  0.168 -0.732    -0.396 -0.099                                
## wSCOREMAT:.  -0.026 -0.435    -0.034  0.162  0.288                         
## vs_mnrty:.Y   0.451 -0.037    -0.550 -0.839  0.265        0.008            
## wSCOREMAT:_: -0.132  0.414     0.263  0.169 -0.552       -0.758      -0.416
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
# Plot interactions
plot_model(res.mlm.7, type = 'pred', terms = c('wSCOREMAT', 'vis_minority', 'delta.Year'))

# Check if model with three-way interaction significantly improves over two-way interactions (model 3)
anova(res.mlm.3, res.mlm.7)

7.1.8 Model 8: Gentrification & bike lanes

Here, SES is measured through gentrification status and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area. Using 2006 as reference year.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi)  %>%
  mutate(delta.Year = Year - 2006)

res.mlm.8 <- lmer(bike_lane.by.street ~ factor(gentrified)*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
summary(res.mlm.8)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bike_lane.by.street ~ factor(gentrified) * delta.Year + (1 |  
##     CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##  11673.1  11706.7  -5830.6  11661.1     1991 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8787 -0.5363 -0.0127  0.4797  3.9410 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 23.081   4.804   
##  Residual              9.962   3.156   
## Number of obs: 1997, groups:  CT_UID, 691
## 
## Fixed effects:
##                                   Estimate Std. Error t value
## (Intercept)                        6.74580    0.23623  28.556
## factor(gentrified)TRUE            -2.40404    0.29387  -8.181
## delta.Year                         0.47163    0.02195  21.485
## factor(gentrified)TRUE:delta.Year  0.44069    0.04161  10.590
## 
## Correlation of Fixed Effects:
##             (Intr) fc()TRUE dlt.Yr
## fctr(g)TRUE -0.399                
## delta.Year  -0.487  0.432         
## fc()TRUE:.Y  0.291 -0.710   -0.600
# Plot interactions
plot_model(res.mlm.8, type = 'pred', terms = c('gentrified', 'delta.Year'))

7.1.9 Model 9: Gentrification & esp_vert

Here, SES is measured through gentrification status and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area. Using 2006 as reference year.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi)  %>%
  mutate(delta.Year = Year - 2006)

res.mlm.9 <- lmer(pct_esp_vert ~ factor(gentrified)*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
summary(res.mlm.9)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: pct_esp_vert ~ factor(gentrified) * delta.Year + (1 | CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##   8691.4   8722.7  -4339.7   8679.4     1357 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -8.2575 -0.3735 -0.0241  0.3650  8.5444 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 149.043  12.208  
##  Residual               3.732   1.932  
## Number of obs: 1363, groups:  CT_UID, 689
## 
## Fixed effects:
##                                   Estimate Std. Error t value
## (Intercept)                       32.44059    0.51570  62.906
## factor(gentrified)TRUE            -1.89689    0.46658  -4.066
## delta.Year                         0.71055    0.02757  25.769
## factor(gentrified)TRUE:delta.Year  0.21239    0.05747   3.696
## 
## Correlation of Fixed Effects:
##             (Intr) fc()TRUE dlt.Yr
## fctr(g)TRUE -0.285                
## delta.Year  -0.405  0.600         
## fc()TRUE:.Y  0.261 -0.920   -0.646
# Plot interactions
plot_model(res.mlm.9, type = 'pred', terms = c('gentrified', 'delta.Year'))

7.1.10 Model 10: Gentrification & esp_vert

Here, SES is measured through gentrification status and urban conditions as the ratio of bike lanes to streets within 500m buffers around CT for the INTERACT study area. Using 2006 as reference year.

# Define multilevel model | buf 500m / INTERACT study area
mlm_data <- bei_df_mlm %>%
  filter(Spatial.scale == 'b500' & interact_aoi)  %>%
  mutate(delta.Year = Year - 2006)

res.mlm.10 <- lmer(pct_esp_vert_high ~ factor(gentrified)*delta.Year + (1 | CT_UID), data = mlm_data, REML = FALSE)
summary(res.mlm.10)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: pct_esp_vert_high ~ factor(gentrified) * delta.Year + (1 | CT_UID)
##    Data: mlm_data
## 
##      AIC      BIC   logLik deviance df.resid 
##   7330.6   7361.9  -3659.3   7318.6     1357 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.97493 -0.40607 -0.00555  0.40257  3.14651 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  CT_UID   (Intercept) 54.531   7.385   
##  Residual              1.385   1.177   
## Number of obs: 1363, groups:  CT_UID, 689
## 
## Fixed effects:
##                                   Estimate Std. Error t value
## (Intercept)                       14.96985    0.31234  47.927
## factor(gentrified)TRUE            -2.08819    0.28420  -7.348
## delta.Year                         0.52563    0.01680  31.294
## factor(gentrified)TRUE:delta.Year  0.25392    0.03501   7.253
## 
## Correlation of Fixed Effects:
##             (Intr) fc()TRUE dlt.Yr
## fctr(g)TRUE -0.287                
## delta.Year  -0.408  0.600         
## fc()TRUE:.Y  0.262 -0.920   -0.646
# Plot interactions
plot_model(res.mlm.10, type = 'pred', terms = c('gentrified', 'delta.Year'))

7.2 Looking for the right modeling framework

Four possible approaches:

  • simple linear regression / mixed-effect model (no spatial effect, packages stats and lme4)
  • spatial auto-regessive model (package spatialreg)
  • spatial random-effect model (package spaMM)
  • Integrated Nested Laplace Approximation (INLA, package r-inla)

To be checked:

  • choice of distribution ? (Poisson vs. zero-inflated poisson vs Gaussian)
  • using buffered data or not ?
  • spatial auto-correlation of residuals ?

7.2.1 Urban condition vs. SES: bike lanes vs. Pampalon material score

# (Re) compute length of streets by CT
street_length_by_CT16 <- compute_streetlength_by_area(CT16) %>%
  as.data.frame() %>%
  transmute(CT_UID = GeoUID,
            street_length = street_length)
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
## Joining, by = "GeoUID"
# Extract variables of interest (dropping units and NA's)
test_df <- bei_df_aoi %>%
  mutate(wSCOREMAT.2011.Q = ntile(wSCOREMAT.2011, 5)) %>% # Add Pampalon material score quantiles
  select(CT_UID, Population, 
         wSCOREMAT.2011,
         wSCOREMAT.2011.Q,
         Bike_lane_total.2011ct, Bike_lane_total.2011b500, 
         Bike_lane.by.street.2011ct, Bike_lane.by.street.2011b500) %>%
  left_join(street_length_by_CT16, by="CT_UID") %>%
  drop_na() %>%
  units::drop_units()

# Add geometry
test_df_w_geom <- CT16 %>%
  transmute(CT_UID = GeoUID) %>%
  inner_join(test_df, by="CT_UID") %>%
  mutate(ct_no = row_number())

# Compute Queen neighborhoods, weights and contiguity matrix
test_ct_nb <- poly2nb(test_df_w_geom)
test_nbw <- nb2listw(test_ct_nb, zero.policy = TRUE)
test_nb_mtx <- nb2mat(test_ct_nb, style = "B", zero.policy = TRUE)

# Display histogram of dependant variable
ggplot(test_df_w_geom) +
  geom_histogram(aes(Bike_lane.by.street.2011ct))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

7.2.1.1 Simple OLS

Solving the following equation:

\[BikeLane.by.street.2011ct=\beta_{0} + \beta_{1}*wSCOREMAT.2011 + \epsilon\]

test.uc.lm <- lm(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, data = test_df_w_geom)
summary(test.uc.lm)
## 
## Call:
## lm(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, data = test_df_w_geom)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.200  -7.709  -2.064   5.143  59.255 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      8.8868     0.3611  24.613  < 2e-16 ***
## wSCOREMAT.2011 -27.1407     8.8021  -3.083  0.00213 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.409 on 688 degrees of freedom
## Multiple R-squared:  0.01363,    Adjusted R-squared:  0.0122 
## F-statistic: 9.508 on 1 and 688 DF,  p-value: 0.002128
# Manually compute residual spatial auto-correlation
test.uc.lm.moran <- moran.test(resid(test.uc.lm), test_nbw, zero.policy = TRUE)
test.uc.lm.moran
## 
##  Moran I test under randomisation
## 
## data:  resid(test.uc.lm)  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 10.193, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2332279498     -0.0014556041      0.0005300653

7.2.1.2 Spatial auto-regressive model

Now, adding an auto-regressive term controled by a \(W\) contiguity matrix:

\[BikeLane.by.street.2011ct=\rho*W*BikeLane.by.street.2011ct + \beta*wSCOREMAT.2011 + \epsilon\]

test.uc.sar <- lagsarlm(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, data = test_df_w_geom, listw = test_nbw, zero.policy = TRUE)
summary(test.uc.sar)
## 
## Call:lagsarlm(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, 
##     data = test_df_w_geom, listw = test_nbw, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -14.9240  -6.2650  -2.3302   4.5959  59.7119 
## 
## Type: lag 
## Regions with no neighbours included:
##  278 467 
## Coefficients: (asymptotic standard errors) 
##                 Estimate Std. Error z value Pr(>|z|)
## (Intercept)      4.79716    0.52801  9.0854  < 2e-16
## wSCOREMAT.2011 -15.20568    8.10776 -1.8754  0.06073
## 
## Rho: 0.46665, LR test value: 84.682, p-value: < 2.22e-16
## Asymptotic standard error: 0.046213
##     z-value: 10.098, p-value: < 2.22e-16
## Wald statistic: 101.97, p-value: < 2.22e-16
## 
## Log likelihood: -2482.463 for lag model
## ML residual variance (sigma squared): 74.646, (sigma: 8.6398)
## Number of observations: 690 
## Number of parameters estimated: 4 
## AIC: 4972.9, (AIC for lm: 5055.6)
## LM test for residual autocorrelation
## test value: 5.4455, p-value: 0.019619
# Check residual spatial auto-correlation (should be null)
test.uc.sar.moran <- moran.test(resid(test.uc.sar), test_nbw, zero.policy = TRUE)
test.uc.sar.moran
## 
##  Moran I test under randomisation
## 
## data:  resid(test.uc.sar)  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = -0.50329, p-value = 0.6926
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.013032659      -0.001455604       0.000529136

7.2.1.3 Spatial auto-regressive model, CTs with bike lanes only

Sensitivity analysis of zero-inflated distribution, still using Gaussian distribution although a Poisson would seem a better fit

test_df_w_geom_no_zero <- CT16 %>%
  transmute(CT_UID = GeoUID) %>%
  inner_join(test_df, by="CT_UID") %>%
  filter(Bike_lane.by.street.2011ct > 0)

# Display histogram of dependant variable
ggplot(test_df_w_geom_no_zero) +
  geom_histogram(aes(Bike_lane.by.street.2011ct))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

# Compute Queen neighborhoods and weights
test_ct_nb_no_zero <- poly2nb(test_df_w_geom_no_zero)
test_nbw_no_zero <- nb2listw(test_ct_nb_no_zero, zero.policy = TRUE)

# Compute SAR model
test.uc.sar_no_zero <- lagsarlm(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, 
                                data = test_df_w_geom_no_zero, 
                                listw = test_nbw_no_zero, zero.policy = TRUE)
summary(test.uc.sar_no_zero)
## 
## Call:lagsarlm(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, 
##     data = test_df_w_geom_no_zero, listw = test_nbw_no_zero, 
##     zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.2540  -6.1457  -1.5540   4.8046  55.8409 
## 
## Type: lag 
## Regions with no neighbours included:
##  345 
## Coefficients: (asymptotic standard errors) 
##                 Estimate Std. Error z value Pr(>|z|)
## (Intercept)      9.00407    0.80204 11.2264   <2e-16
## wSCOREMAT.2011 -12.24859   10.40474 -1.1772   0.2391
## 
## Rho: 0.27172, LR test value: 21.762, p-value: 3.0857e-06
## Asymptotic standard error: 0.056569
##     z-value: 4.8033, p-value: 1.5604e-06
## Wald statistic: 23.072, p-value: 1.5604e-06
## 
## Log likelihood: -1770.959 for lag model
## ML residual variance (sigma squared): 76.928, (sigma: 8.7709)
## Number of observations: 492 
## Number of parameters estimated: 4 
## AIC: 3549.9, (AIC for lm: 3569.7)
## LM test for residual autocorrelation
## test value: 1.6157, p-value: 0.2037
# Check residual spatial auto-correlation (should be null)
test.uc.sar_no_zero.moran <- moran.test(resid(test.uc.sar_no_zero), test_nbw_no_zero, zero.policy = TRUE)
test.uc.sar_no_zero.moran
## 
##  Moran I test under randomisation
## 
## data:  resid(test.uc.sar_no_zero)  
## weights: test_nbw_no_zero  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = -0.13732, p-value = 0.5546
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##     -0.0063363001     -0.0020408163      0.0009784764

7.2.1.4 Spatial random-effect model

Again, adding a random effect term to the simple fixed (no auto-regressive) effect equation:

\[BikeLane.by.street.2011ct=\beta_{0} + \beta_{1}*wSCOREMAT.2011 + b_{i} + \epsilon\] where \(b_{i}\): Gaussian random effect following a conditional autoregressive (CAR) correlation model with a covariance matrix of the form \(\lambda * (I - \rho * N)^{-1}\), \(N\) being an adjacency matrix.

test.uc.smm <- fitme(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + adjacency(1|ct_no),
                  data = test_df_w_geom, adjMatrix = test_nb_mtx)
## Warning in .sym_checked(adjMatrix, "adjMatrix"): Forcing colnames(mMatrix) <-
## rownames(mMatrix) before calling isSymmetric().
summary(test.uc.smm)
## formula: Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + adjacency(1 | ct_no)
## ML: Estimation of corrPars, lambda and phi by ML.
##     Estimation of fixed effects by ML.
## Estimation of lambda and phi by 'outer' ML, maximizing p_v.
## family: gaussian( link = identity ) 
##  ------------ Fixed effects (beta) ------------
##                Estimate Cond. SE t-value
## (Intercept)       10.22   0.6454  15.834
## wSCOREMAT.2011   -14.57  10.3868  -1.403
##  --------------- Random effects ---------------
## Family: gaussian( link = identity ) 
##                    --- Correlation parameters:
##     1.rho 
## 0.1286471 
##            --- Variance parameters ('lambda'):
## lambda = var(u) for u ~ Gaussian; 
##    ct_no  :  69.15  
## # of obs: 690; # of groups: ct_no, 690 
##  -------------- Residual variance  ------------
## phi estimate was 4.59552 
##  ------------- Likelihood values  -------------
##                         logLik
## p_v(h) (marginal L): -2488.894
test.uc.smm.moran <- moran.test(residuals.HLfit(test.uc.smm), test_nbw, zero.policy = TRUE)
test.uc.smm.moran
## 
##  Moran I test under randomisation
## 
## data:  residuals.HLfit(test.uc.smm)  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = -5.0433, p-value = 1
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##     -0.1175338386     -0.0014556041      0.0005297423

7.2.1.5 INLA, as is

test.uc.inla <- inla(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011,
                     data = test_df_w_geom,
                     control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla)
## 
## Call:
##    c("inla(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011, data = 
##    test_df_w_geom, ", " control.compute = list(dic = TRUE, waic = TRUE, 
##    cpo = TRUE))" ) 
## Time used:
##     Pre = 1.99, Running = 0.219, Post = 0.0122, Total = 2.22 
## Fixed effects:
##                   mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)      8.877 0.361      8.168    8.877      9.585   8.877   0
## wSCOREMAT.2011 -25.190 8.478    -41.833  -25.193     -8.548 -25.197   0
## 
## Model hyperparameters:
##                                          mean    sd 0.025quant 0.5quant
## Precision for the Gaussian observations 0.011 0.001       0.01    0.011
##                                         0.975quant  mode
## Precision for the Gaussian observations      0.013 0.011
## 
## Deviance Information Criterion (DIC) ...............: 5055.59
## Deviance Information Criterion (DIC, saturated) ....: 17125.11
## Effective number of parameters .....................: 2.96
## 
## Watanabe-Akaike information criterion (WAIC) ...: 5058.07
## Effective number of parameters .................: 5.30
## 
## Marginal log-Likelihood:  -2542.96 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla_resid <- test_df_w_geom %>%
  mutate(fitted.values = test.uc.inla$summary.fitted.values$mean,
         resid = Bike_lane.by.street.2011ct - fitted.values)

summary(test.uc.inla_resid$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -11.951  -7.766  -2.049   0.000   5.161  58.975
test.uc.inla.moran <- moran.test(test.uc.inla_resid$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.moran
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 10.232, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.234115774      -0.001455604       0.000530088
gbl <- ggplot(test.uc.inla_resid) + geom_sf(aes(fill=Bike_lane.by.street.2011ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla_resid$Bike_lane.by.street.2011ct)))
gfv <- ggplot(test.uc.inla_resid) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla_resid$Bike_lane.by.street.2011ct)))
grd <- ggplot(test.uc.inla_resid) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.1.6 INLA, IID random effect

test.uc.inla.iid <- inla(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + f(ct_no, model='iid'),
                         data = test_df_w_geom,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE, return.marginals.predictor=TRUE))
summary(test.uc.inla.iid)
## 
## Call:
##    c("inla(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + ", " 
##    f(ct_no, model = \"iid\"), data = test_df_w_geom, control.compute = 
##    list(dic = TRUE, ", " waic = TRUE, cpo = TRUE, 
##    return.marginals.predictor = TRUE))" ) 
## Time used:
##     Pre = 2.13, Running = 0.891, Post = 0.0289, Total = 3.05 
## Fixed effects:
##                   mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)      8.877 0.361      8.168    8.877      9.585   8.877   0
## wSCOREMAT.2011 -25.190 8.479    -41.834  -25.192     -8.547 -25.197   0
## 
## Random effects:
##   Name     Model
##     ct_no IID model
## 
## Model hyperparameters:
##                                             mean       sd 0.025quant 0.5quant
## Precision for the Gaussian observations 1.83e+04 1.87e+04    1282.51 1.28e+04
## Precision for ct_no                     1.10e-02 1.00e-03       0.01 1.10e-02
##                                         0.975quant     mode
## Precision for the Gaussian observations   6.83e+04 3533.028
## Precision for ct_no                       1.30e-02    0.011
## 
## Deviance Information Criterion (DIC) ...............: -3346.94
## Deviance Information Criterion (DIC, saturated) ....: 8723.64
## Effective number of parameters .....................: 1078.75
## 
## Watanabe-Akaike information criterion (WAIC) ...: -3571.49
## Effective number of parameters .................: 660.76
## 
## Marginal log-Likelihood:  -2543.04 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.iid_resid <- test_df_w_geom %>%
  mutate(fitted.values = test.uc.inla.iid$summary.fitted.values$mean,
         resid = Bike_lane.by.street.2011ct - fitted.values)

summary(test.uc.inla.iid_resid$resid)
##       Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
## -3.541e-05 -2.272e-05 -5.347e-06  8.252e-07  1.651e-05  1.795e-04
test.uc.inla.iid.moran <- moran.test(test.uc.inla.iid_resid$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.iid.moran
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.iid_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 10.227, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2340101669     -0.0014556041      0.0005300833
gbl <- ggplot(test.uc.inla.iid_resid) + geom_sf(aes(fill=Bike_lane.by.street.2011ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla.iid_resid$Bike_lane.by.street.2011ct)))
gfv <- ggplot(test.uc.inla.iid_resid) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla.iid_resid$Bike_lane.by.street.2011ct)))
grd <- ggplot(test.uc.inla.iid_resid) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.1.7 INLA, IID + BYM random effect

test.uc.inla.bym <- inla(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + f(ct_no, model='bym', graph=test_nb_mtx),
                         data = test_df_w_geom,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla.bym)
## 
## Call:
##    c("inla(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + ", " 
##    f(ct_no, model = \"bym\", graph = test_nb_mtx), data = test_df_w_geom, 
##    ", " control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))" ) 
## Time used:
##     Pre = 2.22, Running = 1.19, Post = 0.0268, Total = 3.43 
## Fixed effects:
##                   mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)      8.881 0.361      8.171    8.881      9.590   8.881   0
## wSCOREMAT.2011 -25.488 8.500    -42.173  -25.490     -8.804 -25.495   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM model
## 
## Model hyperparameters:
##                                             mean       sd 0.025quant 0.5quant
## Precision for the Gaussian observations    0.011    0.001       0.01    0.011
## Precision for ct_no (iid component)     2232.258 2202.333     189.51 1591.128
## Precision for ct_no (spatial component) 2303.082 2260.061     212.10 1647.680
##                                         0.975quant    mode
## Precision for the Gaussian observations      0.013   0.011
## Precision for ct_no (iid component)       8117.885 535.390
## Precision for ct_no (spatial component)   8345.990 602.383
## 
## Deviance Information Criterion (DIC) ...............: 5057.23
## Deviance Information Criterion (DIC, saturated) ....: 17126.75
## Effective number of parameters .....................: 4.88
## 
## Watanabe-Akaike information criterion (WAIC) ...: 5059.01
## Effective number of parameters .................: 6.12
## 
## Marginal log-Likelihood:  -2425.88 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym_resid <- test_df_w_geom %>%
  mutate(fitted.values = test.uc.inla.bym$summary.fitted.values$mean,
         resid = Bike_lane.by.street.2011ct - fitted.values)

summary(test.uc.inla.bym_resid$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -11.991  -7.747  -2.013   0.000   5.044  59.014
test.uc.inla.bym.moran <- moran.test(test.uc.inla.bym_resid$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.bym.moran
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 10.253, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2345978803     -0.0014556041      0.0005300583
gbl <- ggplot(test.uc.inla.bym_resid) + geom_sf(aes(fill=Bike_lane.by.street.2011ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla.bym_resid$Bike_lane.by.street.2011ct)))
gfv <- ggplot(test.uc.inla.bym_resid) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla.bym_resid$Bike_lane.by.street.2011ct)))
grd <- ggplot(test.uc.inla.bym_resid) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.1.8 INLA, IID + BYM random effect, CT’s with bike lanes only

Sensitivity analysis of zero-inflated distribution, still using Gaussian distribution although a Poisson would seem a better fit

test_df_w_geom_no_zero <- CT16 %>%
  transmute(CT_UID = GeoUID) %>%
  inner_join(test_df, by="CT_UID") %>%
  filter(Bike_lane.by.street.2011ct > 0) %>%
  mutate(ct_no = row_number())

# Compute Queen neighborhoods and weights
test_ct_nb_no_zero <- poly2nb(test_df_w_geom_no_zero)
test_nbw_no_zero <- nb2listw(test_ct_nb_no_zero, zero.policy = TRUE)
test_nb_mtx_no_zero <- nb2mat(test_ct_nb_no_zero, style = "B", zero.policy = TRUE)

# INLA
test.uc.inla.bym_no_zero <- inla(Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + f(ct_no, model='bym', graph=test_nb_mtx_no_zero),
                         data = test_df_w_geom_no_zero,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla.bym_no_zero)
## 
## Call:
##    c("inla(formula = Bike_lane.by.street.2011ct ~ wSCOREMAT.2011 + ", " 
##    f(ct_no, model = \"bym\", graph = test_nb_mtx_no_zero), data = 
##    test_df_w_geom_no_zero, ", " control.compute = list(dic = TRUE, waic = 
##    TRUE, cpo = TRUE))" ) 
## Time used:
##     Pre = 2.17, Running = 0.781, Post = 0.0238, Total = 2.98 
## Fixed effects:
##                   mean     sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)     12.287  0.410     11.482   12.287     13.092  12.287   0
## wSCOREMAT.2011 -15.237 10.193    -35.249  -15.240      4.771 -15.245   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM model
## 
## Model hyperparameters:
##                                             mean       sd 0.025quant 0.5quant
## Precision for the Gaussian observations    0.012    0.001      0.011    0.012
## Precision for ct_no (iid component)     1676.121 1738.470    107.047 1154.234
## Precision for ct_no (spatial component) 1408.646 1612.069     85.559  914.919
##                                         0.975quant    mode
## Precision for the Gaussian observations      0.014   0.012
## Precision for ct_no (iid component)       6330.176 287.760
## Precision for ct_no (spatial component)   5732.057 229.543
## 
## Deviance Information Criterion (DIC) ...............: 3570.87
## Deviance Information Criterion (DIC, saturated) ....: 15640.46
## Effective number of parameters .....................: 3.80
## 
## Watanabe-Akaike information criterion (WAIC) ...: 3573.39
## Effective number of parameters .................: 5.90
## 
## Marginal log-Likelihood:  -1633.73 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym_resid_no_zero <- test_df_w_geom_no_zero %>%
  mutate(fitted.values = test.uc.inla.bym_no_zero$summary.fitted.values$mean,
         resid = Bike_lane.by.street.2011ct - fitted.values)

summary(test.uc.inla.bym_resid_no_zero$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -14.105  -6.284  -1.742   0.000   4.702  54.078
test.uc.inla.bym_no_zero.moran <- moran.test(test.uc.inla.bym_resid_no_zero$resid, test_nbw_no_zero, zero.policy = TRUE)
test.uc.inla.bym_no_zero.moran
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym_resid_no_zero$resid  
## weights: test_nbw_no_zero  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 5.0223, p-value = 2.553e-07
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1551396478     -0.0020408163      0.0009794696
gbl <- ggplot(test.uc.inla.bym_resid_no_zero) + geom_sf(aes(fill=Bike_lane.by.street.2011ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla.bym_resid_no_zero$Bike_lane.by.street.2011ct)))
gfv <- ggplot(test.uc.inla.bym_resid_no_zero) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(0,max(test.uc.inla.bym_resid_no_zero$Bike_lane.by.street.2011ct)))
grd <- ggplot(test.uc.inla.bym_resid_no_zero) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.1.9 INLA, IID + BYM random effect, Poisson distribution

Testing various declinations of INLA using Poisson distribution, including parameterization similar to Caislin’s take, that is instead of ratio of bike lanes per streets within neighborhood, we look at absolute bike lane length (with street length offset)

7.2.1.9.1 Casilin’s formula
  • absolute bike lane length in km
  • using Pampalon quintiles
  • expected distribution: street length in km
  • using BYM2 instead of BYM
  • using Poisson distribution instead of Gaussian
# Adapt DF to our needs
test_df_pois <- test_df_w_geom %>%
  transmute(CT_UID = CT_UID,
            ct_no = ct_no,
            wSCOREMAT.2011 = wSCOREMAT.2011,
            wSCOREMAT.2011.Q = wSCOREMAT.2011.Q,
            blane_km = as.integer(Bike_lane_total.2011ct/1000),
            street_km = as.integer(street_length/1000),
            exp_blane_km = street_km * sum(blane_km) / sum(street_km))

# Replicating Caislin's formula || using quintile
test.uc.inla.bym.pois <- inla(blane_km ~ wSCOREMAT.2011.Q + 
                                f(ct_no, model='bym2', graph=test_nb_mtx, scale.model = TRUE),
                         data = test_df_pois,
                         family = "poisson", E = street_km,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
## Warning in inla.model.properties.generic(inla.trim.family(model), mm[names(mm) == : Model 'bym2' in section 'latent' is marked as 'experimental'; changes may appear at any time.
##   Use this model with extra care!!! Further warnings are disabled.
summary(test.uc.inla.bym.pois)
## 
## Call:
##    c("inla(formula = blane_km ~ wSCOREMAT.2011.Q + f(ct_no, model = 
##    \"bym2\", ", " graph = test_nb_mtx, scale.model = TRUE), family = 
##    \"poisson\", ", " data = test_df_pois, E = street_km, control.compute = 
##    list(dic = TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 15, Running = 4.08, Post = 0.0369, Total = 19.1 
## Fixed effects:
##                    mean    sd 0.025quant 0.5quant 0.975quant   mode kld
## (Intercept)      -2.472 0.131     -2.733   -2.471     -2.218 -2.468   0
## wSCOREMAT.2011.Q -0.179 0.042     -0.263   -0.179     -0.097 -0.179   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM2 model
## 
## Model hyperparameters:
##                      mean    sd 0.025quant 0.5quant 0.975quant  mode
## Precision for ct_no 2.534 0.423      1.834    2.487      3.494 2.387
## Phi for ct_no       0.286 0.116      0.099    0.273      0.544 0.241
## 
## Deviance Information Criterion (DIC) ...............: 1461.17
## Deviance Information Criterion (DIC, saturated) ....: -10233.98
## Effective number of parameters .....................: 144.79
## 
## Watanabe-Akaike information criterion (WAIC) ...: 1452.93
## Effective number of parameters .................: 108.96
## 
## Marginal log-Likelihood:  -493.50 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym.pois_resid <- test_df_pois %>%
  mutate(fitted.values = log(test.uc.inla.bym.pois$summary.fitted.values$mean), #Apply link function
         resid = blane_km - fitted.values)

summary(test.uc.inla.bym.pois_resid$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.315   3.009   3.394   3.961   4.115  29.008
test.uc.inla.bym.pois.moran <- moran.test(test.uc.inla.bym.pois_resid$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.bym.pois.moran
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym.pois_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 12.576, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2773685649     -0.0014556041      0.0004915798

wSCOREMAT.2011.Q coefficient = 0.179 (CI 95%: -0.263 – -0.097), which translates into a relative risk of 0.84 (CI95% 0.77 – 0.91). Interpretation: one increment of quintile means 16% less bike lane length in CT.

7.2.1.9.2 Using absolute Pampalon score instead of quintiles
# Replicating Caislin's formula, this time using raw score mat instead of Quintile
test.uc.inla.bym.pois.0 <- inla(blane_km ~ wSCOREMAT.2011 + 
                                f(ct_no, model='bym2', graph=test_nb_mtx, scale.model = TRUE),
                         data = test_df_pois,
                         family = "poisson", E = street_km,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla.bym.pois.0)
## 
## Call:
##    c("inla(formula = blane_km ~ wSCOREMAT.2011 + f(ct_no, model = 
##    \"bym2\", ", " graph = test_nb_mtx, scale.model = TRUE), family = 
##    \"poisson\", ", " data = test_df_pois, E = street_km, control.compute = 
##    list(dic = TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 15.7, Running = 4.51, Post = 0.0375, Total = 20.3 
## Fixed effects:
##                  mean    sd 0.025quant 0.5quant 0.975quant   mode kld
## (Intercept)    -2.979 0.063     -3.106   -2.978     -2.858 -2.975   0
## wSCOREMAT.2011 -6.451 1.486     -9.385   -6.446     -3.549 -6.436   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM2 model
## 
## Model hyperparameters:
##                      mean    sd 0.025quant 0.5quant 0.975quant  mode
## Precision for ct_no 2.532 0.420      1.834    2.487      3.480 2.389
## Phi for ct_no       0.297 0.117      0.105    0.286      0.553 0.258
## 
## Deviance Information Criterion (DIC) ...............: 1460.88
## Deviance Information Criterion (DIC, saturated) ....: -10234.26
## Effective number of parameters .....................: 143.97
## 
## Watanabe-Akaike information criterion (WAIC) ...: 1452.65
## Effective number of parameters .................: 108.39
## 
## Marginal log-Likelihood:  -489.67 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym.pois_resid.0 <- test_df_pois %>%
  mutate(fitted.values = log(test.uc.inla.bym.pois.0$summary.fitted.values$mean), #Apply link function
         resid = blane_km - fitted.values)

summary(test.uc.inla.bym.pois_resid.0$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.111   3.018   3.384   3.964   4.104  29.013
test.uc.inla.bym.pois.moran.0 <- moran.test(test.uc.inla.bym.pois_resid.0$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.bym.pois.moran.0
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym.pois_resid.0$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 12.488, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2754440560     -0.0014556041      0.0004916525
7.2.1.9.3 Using expected bike lane instead of street length
# Replicating Caislin's formula, this time using an expected bike lane length computed from mean of bklane / streets
test.uc.inla.bym.pois.1 <- inla(blane_km ~ wSCOREMAT.2011 + 
                                f(ct_no, model='bym2', graph=test_nb_mtx, scale.model = TRUE),
                         data = test_df_pois,
                         family = "poisson", E = exp_blane_km,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla.bym.pois.1)
## 
## Call:
##    c("inla(formula = blane_km ~ wSCOREMAT.2011 + f(ct_no, model = 
##    \"bym2\", ", " graph = test_nb_mtx, scale.model = TRUE), family = 
##    \"poisson\", ", " data = test_df_pois, E = exp_blane_km, 
##    control.compute = list(dic = TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 16.2, Running = 5.55, Post = 0.0828, Total = 21.8 
## Fixed effects:
##                  mean    sd 0.025quant 0.5quant 0.975quant   mode kld
## (Intercept)    -0.392 0.063     -0.519   -0.391     -0.271 -0.389   0
## wSCOREMAT.2011 -6.450 1.485     -9.382   -6.445     -3.550 -6.435   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM2 model
## 
## Model hyperparameters:
##                      mean    sd 0.025quant 0.5quant 0.975quant  mode
## Precision for ct_no 2.537 0.417       1.85    2.489      3.487 2.384
## Phi for ct_no       0.296 0.114       0.11    0.284      0.547 0.255
## 
## Deviance Information Criterion (DIC) ...............: 1461.15
## Deviance Information Criterion (DIC, saturated) ....: -6836.62
## Effective number of parameters .....................: 143.82
## 
## Watanabe-Akaike information criterion (WAIC) ...: 1452.99
## Effective number of parameters .................: 108.33
## 
## Marginal log-Likelihood:  -490.17 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym.pois_resid.1 <- test_df_pois %>%
  mutate(fitted.values = log(test.uc.inla.bym.pois.1$summary.fitted.values$mean), #Apply link function
         resid = blane_km - fitted.values)

summary(test.uc.inla.bym.pois_resid.1$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.4761  0.4319  0.7970  1.3775  1.5175 26.4275
test.uc.inla.bym.pois.moran.1 <- moran.test(test.uc.inla.bym.pois_resid.1$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.bym.pois.moran.1
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym.pois_resid.1$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 12.488, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2754425686     -0.0014556041      0.0004916678
7.2.1.9.4 No offset
# Replicating Caislin's formula, absolute bike lane length instead of relative risk
test.uc.inla.bym.pois.3 <- inla(blane_km ~ wSCOREMAT.2011 + 
                                f(ct_no, model='bym2', graph=test_nb_mtx, scale.model = TRUE),
                         data = test_df_pois,
                         family = "poisson",
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla.bym.pois.3)
## 
## Call:
##    c("inla(formula = blane_km ~ wSCOREMAT.2011 + f(ct_no, model = 
##    \"bym2\", ", " graph = test_nb_mtx, scale.model = TRUE), family = 
##    \"poisson\", ", " data = test_df_pois, control.compute = list(dic = 
##    TRUE, waic = TRUE, ", " cpo = TRUE))") 
## Time used:
##     Pre = 15.3, Running = 4.58, Post = 0.0373, Total = 19.9 
## Fixed effects:
##                   mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)     -0.733 0.078     -0.890   -0.731     -0.584  -0.728   0
## wSCOREMAT.2011 -10.584 1.891    -14.324  -10.575     -6.896 -10.557   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM2 model
## 
## Model hyperparameters:
##                      mean    sd 0.025quant 0.5quant 0.975quant  mode
## Precision for ct_no 0.851 0.092      0.694    0.843      1.053 0.822
## Phi for ct_no       0.374 0.068      0.250    0.371      0.516 0.363
## 
## Deviance Information Criterion (DIC) ...............: 1579.28
## Deviance Information Criterion (DIC, saturated) ....: -7147.29
## Effective number of parameters .....................: 247.74
## 
## Watanabe-Akaike information criterion (WAIC) ...: 1546.29
## Effective number of parameters .................: 164.17
## 
## Marginal log-Likelihood:  -611.02 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym.pois_resid.3 <- test_df_pois %>%
  mutate(fitted.values = log(test.uc.inla.bym.pois.3$summary.fitted.values$mean), #Apply link function
         resid = blane_km - fitted.values)

summary(test.uc.inla.bym.pois_resid.3$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.2355  0.9234  1.2273  1.5234  1.5659 24.7216
test.uc.inla.bym.pois.moran.3 <- moran.test(test.uc.inla.bym.pois_resid.3$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.bym.pois.moran.3
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym.pois_resid.3$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 6.8743, p-value = 3.115e-12
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1476102956     -0.0014556041      0.0004702219
gbl <- ggplot(test.uc.inla.bym.pois_resid.3) + geom_sf(aes(fill=blane_km), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.uc.inla.bym.pois_resid.3$fitted.values),max(test.uc.inla.bym.pois_resid.3$blane_km)))
gfv <- ggplot(test.uc.inla.bym.pois_resid.3) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.uc.inla.bym.pois_resid.3$fitted.values),max(test.uc.inla.bym.pois_resid.3$blane_km)))
grd <- ggplot(test.uc.inla.bym.pois_resid.3) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.1.9.5 No offset and no spatial effect
# Replicating Caislin's formula, this time using an expected bike lane length computed from mean of bklane / streets
test.uc.inla.bym.pois.2 <- inla(blane_km ~ wSCOREMAT.2011 + 
                                f(ct_no, model='iid'), #graph=test_nb_mtx, scale.model = TRUE),
                         data = test_df_pois,
                         family = "poisson", #E = exp_blane_km,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.uc.inla.bym.pois.2)
## 
## Call:
##    c("inla(formula = blane_km ~ wSCOREMAT.2011 + f(ct_no, model = 
##    \"iid\"), ", " family = \"poisson\", data = test_df_pois, 
##    control.compute = list(dic = TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 2.2, Running = 0.736, Post = 0.02, Total = 2.96 
## Fixed effects:
##                   mean    sd 0.025quant 0.5quant 0.975quant    mode kld
## (Intercept)     -0.709 0.088     -0.887   -0.706     -0.545  -0.700   0
## wSCOREMAT.2011 -10.391 1.720    -13.793  -10.383     -7.034 -10.367   0
## 
## Random effects:
##   Name     Model
##     ct_no IID model
## 
## Model hyperparameters:
##                      mean    sd 0.025quant 0.5quant 0.975quant  mode
## Precision for ct_no 0.653 0.076      0.512     0.65      0.792 0.606
## 
## Deviance Information Criterion (DIC) ...............: 1688.08
## Deviance Information Criterion (DIC, saturated) ....: -7038.49
## Effective number of parameters .....................: 313.75
## 
## Watanabe-Akaike information criterion (WAIC) ...: 1639.55
## Effective number of parameters .................: 199.60
## 
## Marginal log-Likelihood:  -976.19 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.uc.inla.bym.pois_resid.2 <- test_df_pois %>%
  mutate(fitted.values = log(test.uc.inla.bym.pois.2$summary.fitted.values$mean), #Apply link function
         resid = blane_km - fitted.values)

summary(test.uc.inla.bym.pois_resid.2$resid)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.07767  0.75518  0.98266  1.36028  1.35405 24.73485
test.uc.inla.bym.pois.moran.2 <- moran.test(test.uc.inla.bym.pois_resid.2$resid, test_nbw, zero.policy = TRUE)
test.uc.inla.bym.pois.moran.2
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym.pois_resid.2$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 10.633, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2289136166     -0.0014556041      0.0004694086
gbl <- ggplot(test.uc.inla.bym.pois_resid.2) + geom_sf(aes(fill=blane_km), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.uc.inla.bym.pois_resid.2$fitted.values),max(test.uc.inla.bym.pois_resid.2$blane_km)))
gfv <- ggplot(test.uc.inla.bym.pois_resid.2) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.uc.inla.bym.pois_resid.2$fitted.values),max(test.uc.inla.bym.pois_resid.2$blane_km)))
grd <- ggplot(test.uc.inla.bym.pois_resid.2) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.1.10 Summary

test.uc.summary <- data.frame(model=c("OLS", "SAR", "SAR, no zero", "Spatial random effect", 
                                      "INLA, simple regression", "INLA, IID random effect", 
                                      "INLA, IID & BYM random effect", "INLA, IID & BYM randmom effect, no zero"),
                              Intercept=c(test.uc.lm$coefficients["(Intercept)"],
                                          test.uc.sar$coefficients["(Intercept)"],
                                          test.uc.sar_no_zero$coefficients["(Intercept)"],
                                          test.uc.smm$fixef["(Intercept)"],
                                          test.uc.inla$summary.fixed$mean[1],
                                          test.uc.inla.iid$summary.fixed$mean[1],
                                          test.uc.inla.bym$summary.fixed$mean[1],
                                          test.uc.inla.bym_no_zero$summary.fixed$mean[1]),
                              wSCOREMAT.2011=c(test.uc.lm$coefficients["wSCOREMAT.2011"],
                                          test.uc.sar$coefficients["wSCOREMAT.2011"],
                                          test.uc.sar_no_zero$coefficients["wSCOREMAT.2011"],
                                          test.uc.smm$fixef["wSCOREMAT.2011"],
                                          test.uc.inla$summary.fixed$mean[2],
                                          test.uc.inla.iid$summary.fixed$mean[2],
                                          test.uc.inla.bym$summary.fixed$mean[2],
                                          test.uc.inla.bym_no_zero$summary.fixed$mean[2]),
                              `Moran's I` = c(paste0(round(test.uc.lm.moran$estimate[1], 4), if (test.uc.lm.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.sar.moran$estimate[1], 4), if (test.uc.sar.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.sar_no_zero.moran$estimate[1], 4), if (test.uc.sar_no_zero.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.smm.moran$estimate[1], 4), if (test.uc.smm.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.inla.moran$estimate[1], 4), if (test.uc.inla.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.inla.iid.moran$estimate[1], 4), if (test.uc.inla.iid.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.inla.bym.moran$estimate[1], 4), if (test.uc.inla.bym.moran$p.value < .05) '*'),
                                              paste0(round(test.uc.inla.bym_no_zero.moran$estimate[1], 4), if (test.uc.inla.bym_no_zero.moran$p.value < .05) '*')))
test.uc.summary

NB INLAs with Poisson distribution not shown.

7.2.2 Urban intervention vs. SES: bike lane change vs. Pampalon material score

# Extract variables of interest (dropping units and NA's)
test_df <- bei_df_aoi %>%
  select(CT_UID, Population, 
         wSCOREMAT.2011, 
         Bike_lane_diff.by.street.2011.2016ct, Bike_lane_diff.by.street.2011.2016b500,
         Bike_lane.by.street.2011ct, Bike_lane.by.street.2011b500) %>%
  left_join(street_length_by_CT16, by="CT_UID") %>%
  drop_na() %>%
  units::drop_units()

# Add geometry
test_df_w_geom <- CT16 %>%
  transmute(CT_UID = GeoUID) %>%
  inner_join(test_df, by="CT_UID") %>%
  mutate(ct_no = row_number())

# Compute Queen neighborhoods, weights and contiguity matrix
test_ct_nb <- poly2nb(test_df_w_geom)
test_nbw <- nb2listw(test_ct_nb, zero.policy = TRUE)
test_nb_mtx <- nb2mat(test_ct_nb, style = "B", zero.policy = TRUE)

# Display histogram of dependant variable
ggplot(test_df_w_geom) +
  geom_histogram(aes(Bike_lane_diff.by.street.2011.2016ct))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

7.2.2.1 Simple OLS

test.ui.lm <- lm(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct, data = test_df_w_geom)
summary(test.ui.lm)
## 
## Call:
## lm(formula = Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + 
##     Bike_lane.by.street.2011ct, data = test_df_w_geom)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.601  -4.253  -3.044   1.520  37.493 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 4.62603    0.37517  12.331  < 2e-16 ***
## wSCOREMAT.2011             -4.12185    6.71541  -0.614 0.539558    
## Bike_lane.by.street.2011ct -0.10651    0.02889  -3.687 0.000245 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.129 on 687 degrees of freedom
## Multiple R-squared:  0.01945,    Adjusted R-squared:  0.0166 
## F-statistic: 6.815 on 2 and 687 DF,  p-value: 0.001173
# Manually compute residual spatial auto-correlation
test.ui.lm.moran <- moran.test(resid(test.ui.lm), test_nbw, zero.policy = TRUE)
test.ui.lm.moran
## 
##  Moran I test under randomisation
## 
## data:  resid(test.ui.lm)  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 16.302, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.3732334955     -0.0014556041      0.0005282523

7.2.2.2 Spatial auto-regressive model

test.ui.sar <- lagsarlm(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct, data = test_df_w_geom, listw = test_nbw, zero.policy = TRUE)
summary(test.ui.sar)
## 
## Call:
## lagsarlm(formula = Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + 
##     Bike_lane.by.street.2011ct, data = test_df_w_geom, listw = test_nbw, 
##     zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -16.23454  -2.67227  -1.57547   0.80541  35.88450 
## 
## Type: lag 
## Regions with no neighbours included:
##  278 467 
## Coefficients: (asymptotic standard errors) 
##                             Estimate Std. Error z value  Pr(>|z|)
## (Intercept)                 1.905412   0.345481  5.5152 3.483e-08
## wSCOREMAT.2011             -2.497674   5.540426 -0.4508   0.65213
## Bike_lane.by.street.2011ct -0.054837   0.023866 -2.2977   0.02158
## 
## Rho: 0.62981, LR test value: 200.15, p-value: < 2.22e-16
## Asymptotic standard error: 0.037203
##     z-value: 16.929, p-value: < 2.22e-16
## Wald statistic: 286.6, p-value: < 2.22e-16
## 
## Log likelihood: -2232.788 for lag model
## ML residual variance (sigma squared): 34.596, (sigma: 5.8818)
## Number of observations: 690 
## Number of parameters estimated: 5 
## AIC: 4475.6, (AIC for lm: 4673.7)
## LM test for residual autocorrelation
## test value: 9.0874, p-value: 0.0025737
# Check residual spatial auto-correlation (should be null)
test.ui.sar.moran <- moran.test(resid(test.ui.sar), test_nbw, zero.policy = TRUE)
test.ui.sar.moran
## 
##  Moran I test under randomisation
## 
## data:  resid(test.ui.sar)  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = -0.95974, p-value = 0.8314
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##     -0.0235015424     -0.0014556041      0.0005276574

7.2.2.3 Spatial random-effect model

test.ui.smm <- fitme(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct + adjacency(1|ct_no),
                  data = test_df_w_geom, adjMatrix = test_nb_mtx)
## Warning in .sym_checked(adjMatrix, "adjMatrix"): Forcing colnames(mMatrix) <-
## rownames(mMatrix) before calling isSymmetric().
summary(test.ui.smm)
## formula: Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct + 
##     adjacency(1 | ct_no)
## ML: Estimation of corrPars, lambda and phi by ML.
##     Estimation of fixed effects by ML.
## Estimation of lambda and phi by 'outer' ML, maximizing p_v.
## family: gaussian( link = identity ) 
##  ------------ Fixed effects (beta) ------------
##                            Estimate Cond. SE t-value
## (Intercept)                 3.45515  0.54599  6.3283
## wSCOREMAT.2011              1.67836  7.12641  0.2355
## Bike_lane.by.street.2011ct -0.05943  0.02607 -2.2798
##  --------------- Random effects ---------------
## Family: gaussian( link = identity ) 
##                    --- Correlation parameters:
##     1.rho 
## 0.1379553 
##            --- Variance parameters ('lambda'):
## lambda = var(u) for u ~ Gaussian; 
##    ct_no  :  24.91  
## # of obs: 690; # of groups: ct_no, 690 
##  -------------- Residual variance  ------------
## phi estimate was 9.12665 
##  ------------- Likelihood values  -------------
##                         logLik
## p_v(h) (marginal L): -2228.689
# Check residual spatial auto-correlation (should be null)
test.ui.smm.moran <- moran.test(resid(test.ui.smm), test_nbw, zero.policy = TRUE)
test.ui.smm.moran
## 
##  Moran I test under randomisation
## 
## data:  resid(test.ui.smm)  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = -4.5479, p-value = 1
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##     -0.1059563028     -0.0014556041      0.0005279903

7.2.2.4 INLA, as is

test.ui.inla <- inla(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct,
                     data = test_df_w_geom,
                     control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.ui.inla)
## 
## Call:
##    c("inla(formula = Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 
##    + ", " Bike_lane.by.street.2011ct, data = test_df_w_geom, 
##    control.compute = list(dic = TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 2.04, Running = 0.238, Post = 0.0139, Total = 2.3 
## Fixed effects:
##                              mean    sd 0.025quant 0.5quant 0.975quant   mode
## (Intercept)                 4.624 0.375      3.888    4.624      5.360  4.624
## wSCOREMAT.2011             -3.944 6.567    -16.841   -3.944      8.943 -3.945
## Bike_lane.by.street.2011ct -0.106 0.029     -0.163   -0.106     -0.050 -0.106
##                            kld
## (Intercept)                  0
## wSCOREMAT.2011               0
## Bike_lane.by.street.2011ct   0
## 
## Model hyperparameters:
##                                         mean    sd 0.025quant 0.5quant
## Precision for the Gaussian observations 0.02 0.001      0.018     0.02
##                                         0.975quant mode
## Precision for the Gaussian observations      0.022 0.02
## 
## Deviance Information Criterion (DIC) ...............: 4673.72
## Deviance Information Criterion (DIC, saturated) ....: 9742.34
## Effective number of parameters .....................: 4.00
## 
## Watanabe-Akaike information criterion (WAIC) ...: 4676.64
## Effective number of parameters .................: 6.79
## 
## Marginal log-Likelihood:  -2357.67 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.ui.inla_resid <- test_df_w_geom %>%
  mutate(fitted.values = test.ui.inla$summary.fitted.values$mean,
         resid = Bike_lane_diff.by.street.2011.2016ct - fitted.values)

summary(test.ui.inla_resid$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -10.602  -4.255  -3.044   0.000   1.524  37.496
test.ui.inla.moran <- moran.test(test.ui.inla_resid$resid, test_nbw, zero.policy = TRUE)
test.ui.inla.moran
## 
##  Moran I test under randomisation
## 
## data:  test.ui.inla_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 16.303, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.3732558632     -0.0014556041      0.0005282516
gbl <- ggplot(test.ui.inla_resid) + geom_sf(aes(fill=Bike_lane_diff.by.street.2011.2016ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.ui.inla_resid$Bike_lane_diff.by.street.2011.2016ct),max(test.ui.inla_resid$Bike_lane_diff.by.street.2011.2016ct)))
gfv <- ggplot(test.ui.inla_resid) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.ui.inla_resid$Bike_lane_diff.by.street.2011.2016ct),max(test.ui.inla_resid$Bike_lane_diff.by.street.2011.2016ct)))
grd <- ggplot(test.ui.inla_resid) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.2.5 INLA, IID random effect

test.ui.inla.iid <- inla(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct + f(ct_no, model='iid'),
                         data = test_df_w_geom,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE, return.marginals.predictor=TRUE))
summary(test.ui.inla.iid)
## 
## Call:
##    c("inla(formula = Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 
##    + ", " Bike_lane.by.street.2011ct + f(ct_no, model = \"iid\"), data = 
##    test_df_w_geom, ", " control.compute = list(dic = TRUE, waic = TRUE, 
##    cpo = TRUE, ", " return.marginals.predictor = TRUE))") 
## Time used:
##     Pre = 2.19, Running = 0.376, Post = 0.033, Total = 2.6 
## Fixed effects:
##                              mean    sd 0.025quant 0.5quant 0.975quant   mode
## (Intercept)                 4.624 0.375      3.888    4.624      5.360  4.624
## wSCOREMAT.2011             -3.944 6.564    -16.835   -3.945      8.937 -3.945
## Bike_lane.by.street.2011ct -0.106 0.029     -0.163   -0.106     -0.050 -0.106
##                            kld
## (Intercept)                  0
## wSCOREMAT.2011               0
## Bike_lane.by.street.2011ct   0
## 
## Random effects:
##   Name     Model
##     ct_no IID model
## 
## Model hyperparameters:
##                                          mean       sd 0.025quant 0.5quant
## Precision for the Gaussian observations 0.171 1.87e+08      0.079    0.160
## Precision for ct_no                     0.022 1.00e-03      0.019    0.022
##                                         0.975quant  mode
## Precision for the Gaussian observations      0.339 0.150
## Precision for ct_no                         22.227 0.022
## 
## Deviance Information Criterion (DIC) ...............: 3946.71
## Deviance Information Criterion (DIC, saturated) ....: 9015.55
## Effective number of parameters .....................: 585.82
## 
## Watanabe-Akaike information criterion (WAIC) ...: 3827.07
## Effective number of parameters .................: 338.08
## 
## Marginal log-Likelihood:  -2367.08 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.ui.inla.iid_resid <- test_df_w_geom %>%
  mutate(fitted.values = test.ui.inla.iid$summary.fitted.values$mean,
         resid = Bike_lane_diff.by.street.2011.2016ct - fitted.values)

summary(test.ui.inla.iid_resid$resid)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -1.597301 -0.640969 -0.458620 -0.000001  0.229614  5.649066
test.ui.inla.iid.moran <- moran.test(test.ui.inla_resid$resid, test_nbw, zero.policy = TRUE)
test.ui.inla.iid.moran
## 
##  Moran I test under randomisation
## 
## data:  test.ui.inla_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 16.303, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.3732558632     -0.0014556041      0.0005282516
gbl <- ggplot(test.ui.inla.iid_resid) + geom_sf(aes(fill=Bike_lane_diff.by.street.2011.2016ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.ui.inla.iid_resid$Bike_lane_diff.by.street.2011.2016ct), max(test.ui.inla.iid_resid$Bike_lane_diff.by.street.2011.2016ct)))
gfv <- ggplot(test.ui.inla.iid_resid) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.ui.inla.iid_resid$Bike_lane_diff.by.street.2011.2016ct), max(test.ui.inla.iid_resid$Bike_lane_diff.by.street.2011.2016ct)))
grd <- ggplot(test.ui.inla.iid_resid) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.2.6 INLA, IID + BYM random effect

test.ui.inla.bym <- inla(Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 + Bike_lane.by.street.2011ct + f(ct_no, model='bym', graph=test_nb_mtx),
                         data = test_df_w_geom,
                         control.compute = list(dic = TRUE, waic = TRUE, cpo = TRUE))
summary(test.ui.inla.bym)
## 
## Call:
##    c("inla(formula = Bike_lane_diff.by.street.2011.2016ct ~ wSCOREMAT.2011 
##    + ", " Bike_lane.by.street.2011ct + f(ct_no, model = \"bym\", graph = 
##    test_nb_mtx), ", " data = test_df_w_geom, control.compute = list(dic = 
##    TRUE, ", " waic = TRUE, cpo = TRUE))") 
## Time used:
##     Pre = 2.25, Running = 1.42, Post = 0.0285, Total = 3.7 
## Fixed effects:
##                              mean    sd 0.025quant 0.5quant 0.975quant   mode
## (Intercept)                 4.641 0.376      3.903    4.641      5.378  4.641
## wSCOREMAT.2011             -4.354 6.590    -17.295   -4.354      8.578 -4.354
## Bike_lane.by.street.2011ct -0.107 0.029     -0.164   -0.107     -0.050 -0.107
##                            kld
## (Intercept)                  0
## wSCOREMAT.2011               0
## Bike_lane.by.street.2011ct   0
## 
## Random effects:
##   Name     Model
##     ct_no BYM model
## 
## Model hyperparameters:
##                                            mean       sd 0.025quant 0.5quant
## Precision for the Gaussian observations    0.02    0.001      0.018     0.02
## Precision for ct_no (iid component)     1632.60 1842.901    110.256  1072.82
## Precision for ct_no (spatial component) 2011.93 2174.670    161.387  1362.01
##                                         0.975quant   mode
## Precision for the Gaussian observations      0.022   0.02
## Precision for ct_no (iid component)       6521.758 297.69
## Precision for ct_no (spatial component)   7824.924 446.93
## 
## Deviance Information Criterion (DIC) ...............: 4676.71
## Deviance Information Criterion (DIC, saturated) ....: 9745.33
## Effective number of parameters .....................: 5.90
## 
## Watanabe-Akaike information criterion (WAIC) ...: 4678.70
## Effective number of parameters .................: 7.39
## 
## Marginal log-Likelihood:  -2241.62 
## CPO and PIT are computed
## 
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Check residuals
test.ui.inla.bym_resid <- test_df_w_geom %>%
  mutate(fitted.values = test.ui.inla.bym$summary.fitted.values$mean,
         resid = Bike_lane_diff.by.street.2011.2016ct - fitted.values)

summary(test.ui.inla.bym_resid$resid)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -10.611  -4.265  -3.053   0.000   1.512  37.475
test.ui.inla.bym.moran <- moran.test(test.uc.inla.bym_resid$resid, test_nbw, zero.policy = TRUE)
test.ui.inla.bym.moran
## 
##  Moran I test under randomisation
## 
## data:  test.uc.inla.bym_resid$resid  
## weights: test_nbw  n reduced by no-neighbour observations
##   
## 
## Moran I statistic standard deviate = 10.253, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.2345978803     -0.0014556041      0.0005300583
gbl <- ggplot(test.ui.inla.bym_resid) + geom_sf(aes(fill=Bike_lane_diff.by.street.2011.2016ct), lwd=.2) + scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.ui.inla.bym_resid$Bike_lane_diff.by.street.2011.2016ct), max(test.ui.inla.bym_resid$Bike_lane_diff.by.street.2011.2016ct)))
gfv <- ggplot(test.ui.inla.bym_resid) + geom_sf(aes(fill=fitted.values), lwd=.2)+ scale_fill_gradient(low = "white", high = "blue",
                            limits = c(min(test.ui.inla.bym_resid$Bike_lane_diff.by.street.2011.2016ct), max(test.ui.inla.bym_resid$Bike_lane_diff.by.street.2011.2016ct)))
grd <- ggplot(test.ui.inla.bym_resid) + geom_sf(aes(fill=resid), lwd=.2)+ scale_fill_gradient(low = "dark blue", high = "red")
cowplot::plot_grid(gbl + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   gfv + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   grd + theme(legend.position="none", axis.ticks = element_blank(), axis.text = element_blank()),
                   labels = c("Bike lanes", "Fitted values", "Residuals"))

7.2.2.7 Summary

test.ui.summary <- data.frame(model=c("OLS", "SAR", "Spatial random effect", 
                                      "INLA, simple regression", "INLA, IID random effect", "INLA, IID & BYM random effect"),
                              Intercept=c(test.ui.lm$coefficients["(Intercept)"],
                                          test.ui.sar$coefficients["(Intercept)"],
                                          test.ui.smm$fixef["(Intercept)"],
                                          test.ui.inla$summary.fixed$mean[1],
                                          test.ui.inla.iid$summary.fixed$mean[1],
                                          test.ui.inla.bym$summary.fixed$mean[1]),
                              wSCOREMAT.2011=c(test.ui.lm$coefficients["wSCOREMAT.2011"],
                                          test.ui.sar$coefficients["wSCOREMAT.2011"],
                                          test.ui.smm$fixef["wSCOREMAT.2011"],
                                          test.ui.inla$summary.fixed$mean[2],
                                          test.ui.inla.iid$summary.fixed$mean[2],
                                          test.ui.inla.bym$summary.fixed$mean[2]),
                              Bike_lane.by.street.2011ct=c(test.ui.lm$coefficients["Bike_lane.by.street.2011ct"],
                                          test.ui.sar$coefficients["Bike_lane.by.street.2011ct"],
                                          test.ui.smm$fixef["Bike_lane.by.street.2011ct"],
                                          test.ui.inla$summary.fixed$mean[3],
                                          test.ui.inla.iid$summary.fixed$mean[3],
                                          test.ui.inla.bym$summary.fixed$mean[3]),
                              `Moran's I` = c(paste0(round(test.ui.lm.moran$estimate[1], 4), if (test.ui.lm.moran$p.value < .05) '*'),
                                              paste0(round(test.ui.sar.moran$estimate[1], 4), if (test.ui.sar.moran$p.value < .05) '*'),
                                              paste0(round(test.ui.smm.moran$estimate[1], 4), if (test.ui.smm.moran$p.value < .05) '*'),
                                              paste0(round(test.ui.inla.moran$estimate[1], 4), if (test.ui.inla.moran$p.value < .05) '*'),
                                              paste0(round(test.ui.inla.iid.moran$estimate[1], 4), if (test.ui.inla.iid.moran$p.value < .05) '*'),
                                              paste0(round(test.ui.inla.bym.moran$estimate[1], 4), if (test.ui.inla.bym.moran$p.value < .05) '*')))
test.ui.summary

7.2.3 Accounting for time in urban condition vs. SES: bike lanes vs. Pampalon material score

7.2.3.1 Simple OLS

7.2.3.2 Spatial auto-regressive model

7.2.3.3 Spatial random-effect model

7.2.3.4 INLA, as is

8 Annexes

## R version 4.1.2 (2021-11-01)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
## 
## attached base packages:
## [1] parallel  stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] cancensus_0.5.0  INLA_21.11.22    foreach_1.5.2    stargazer_5.2.2 
##  [5] spaMM_3.10.0     cachem_1.0.6     memoise_2.0.1    spatialreg_1.2-1
##  [9] spdep_1.2-2      spData_2.0.1     sp_1.4-6         emmeans_1.7.2   
## [13] sjPlot_2.8.10    lme4_1.1-28      Matrix_1.4-0     biscale_0.2.0   
## [17] openxlsx_4.2.5   RPostgres_1.4.3  DBI_1.1.2        cowplot_1.1.1   
## [21] ggmap_3.0.0      ggplot2_3.3.5    stars_0.5-5      abind_1.4-5     
## [25] sf_1.0-6         tidyr_1.2.0      dplyr_1.0.8     
## 
## loaded via a namespace (and not attached):
##   [1] backports_1.4.1     corrplot_0.92       lwgeom_0.2-8       
##   [4] plyr_1.8.6          splines_4.1.2       digest_0.6.29      
##   [7] htmltools_0.5.2     gdata_2.18.0        fansi_1.0.2        
##  [10] magrittr_2.0.2      geojsonsf_2.0.1     modelr_0.1.8       
##  [13] gmodels_2.18.1      jpeg_0.1-9          colorspace_2.0-2   
##  [16] blob_1.2.2          xfun_0.29           crayon_1.5.0       
##  [19] jsonlite_1.7.3      iterators_1.0.14    glue_1.6.1         
##  [22] registry_0.5-1      gtable_0.3.0        MatrixModels_0.5-0 
##  [25] sjstats_0.18.1      sjmisc_2.8.9        car_3.0-12         
##  [28] scales_1.1.1        mvtnorm_1.1-3       ggeffects_1.1.1    
##  [31] Rcpp_1.0.8          xtable_1.8-4        performance_0.8.0  
##  [34] units_0.8-0         bit_4.0.4           proxy_0.4-26       
##  [37] heplots_1.3-9       datawizard_0.2.3    httr_1.4.2         
##  [40] RColorBrewer_1.1-2  wk_0.6.0            ellipsis_0.3.2     
##  [43] pkgconfig_2.0.3     farver_2.1.0        sass_0.4.0         
##  [46] deldir_1.0-6        utf8_1.2.2          tidyselect_1.1.1   
##  [49] labeling_0.4.2      rlang_1.0.1         effectsize_0.6.0.1 
##  [52] munsell_0.5.0       tools_4.1.2         cli_3.2.0          
##  [55] generics_0.1.2      sjlabelled_1.1.8    broom_0.7.12       
##  [58] evaluate_0.15       stringr_1.4.0       fastmap_1.1.0      
##  [61] yaml_2.2.2          knitr_1.37          bit64_4.0.5        
##  [64] zip_2.2.0           purrr_0.3.4         s2_1.0.7           
##  [67] RgoogleMaps_1.4.5.3 pbapply_1.5-0       nlme_3.1-155       
##  [70] slam_0.1-50         ROI_1.0-0           compiler_4.1.2     
##  [73] rstudioapi_0.13     png_0.1-7           e1071_1.7-9        
##  [76] tibble_3.1.6        bslib_0.3.1         stringi_1.7.6      
##  [79] highr_0.9           parameters_0.16.0   lattice_0.20-45    
##  [82] classInt_0.4-3      nloptr_2.0.0        vctrs_0.3.8        
##  [85] pillar_1.7.0        LearnBayes_2.15.1   lifecycle_1.0.1    
##  [88] jquerylib_0.1.4     estimability_1.3    bitops_1.0-7       
##  [91] insight_0.16.0      raster_3.5-15       R6_2.5.1           
##  [94] KernSmooth_2.23-20  codetools_0.2-18    boot_1.3-28        
##  [97] MASS_7.3-55         gtools_3.9.2        assertthat_0.2.1   
## [100] rjson_0.2.21        withr_2.4.3         mgcv_1.8-38        
## [103] bayestestR_0.11.5   expm_0.999-6        hms_1.1.1          
## [106] terra_1.5-21        grid_4.1.2          coda_0.19-4        
## [109] class_7.3-20        minqa_1.2.4         snakecase_0.11.0   
## [112] rmarkdown_2.11      carData_3.0-5       numDeriv_2016.8-1.1
## [115] lubridate_1.8.0